• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:43
CET 16:43
KST 00:43
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (October 19-25): Clem triples first in 5.0.172Evil Geniuses - shutting down17ISSL (IntoTheTV x SOOP SC2 League): Premier5Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League88
StarCraft 2
General
REPORT: StarCraft 2: Remastered In Development No more SC2 streamers on team liquid? Weekly Cups (October 19-25): Clem triples first in 5.0.17 Evil Geniuses - shutting down How do you feel about the mass reverts in the 5.0.17 PTR?
Tourneys
2026 KungFu Cup Announcement RSL goes to London! 2026 Offline Finals Nov 21-22 ScienceCraft (October 24-25) - Live Event Sparkling Tuna Cup - Weekly Open Tournament ISSL (IntoTheTV x SOOP SC2 League): Premier
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
Simple Questions/Answers [G] How to playtest arcade maps [A] Nemrods 1/4 players
External Content
Mutation # 549 Endless Sparkles The PondCast: SC2 News & Results Mutation # 548 Shining Bright Mutation # 547 Temple Of Terror
Brood War
General
[BW] Looking for Clan Thread! BW General Discussion [ASL22] Finals Preview: Sweet Victory! Recent recommended BW games [Megathread] Daily Funny Videos
Tourneys
[Megathread] Daily Proleagues [$1250] International ShieldBattery League KCM Race Survival 2026 Season 4 [BSL23] RO24 Group D - Sunday 21:00 CET
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Mobile Legends: Bang Bang Armies of Exigo - YesYes? General RTS Discussion Thread
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
Reynor Fan Club The Flash Fan Club Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 10948 users

The Big Programming Thread - Page 390

Forum Index > General Forum
Post a Reply
Prev 1 388 389 390 391 392 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17865 Posts
November 11 2013 17:37 GMT
#7781
And remember, extends are evil. Interface inheritance > implementation inheritance.
Time is precious. Waste it wisely.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
November 11 2013 21:18 GMT
#7782
On November 12 2013 02:37 Manit0u wrote:
And remember, extends are evil. Interface inheritance > implementation inheritance.

That's a rather limiting opinion. While it's important to know the difference between "is-a" and "can-do" relationships, saying one is evil is just flat-out wrong.
Average means I'm better than half of you.
misirlou
Profile Joined June 2010
Portugal3319 Posts
November 11 2013 22:12 GMT
#7783
On November 11 2013 11:18 ArchmageKruzer wrote:
For science fair this year, one of my friends is trying to build a program to compare frequencies of chunks of various DNA codes (quite personally I don't really understand it myself, but it's basically you get ~ one million dna bases, and you pick out how many AGTGGACA are in there, rinse and repeat for a ton more chunks). So the obvious way is to just run a loop and compare the data, but that would take a long time as I understand it. Is there a more effective way to do this? (btw, I am really bad at coding. I am extremely good at logic stuff, but idk much syntax and terms and shit. i.e I'm in regular high school programming learning about java. we just got past karel, and are in the middle of if statements) please try not to use too much complicated syntax, or if you do, give me some sort of reference sheet so that I can look at it while I read you post. Ty!


Not really string search related, but a BIG way to speed it up would be using multi threading. I have never made parallel code in Java (although i have created some seperate threads to handle http requests). Don't know if it is as simple as creating a thread and just running it or if something else is involved, have a look at it. From experience, C and openMP are plain simple to use. In your case, you want to analyze several subjects and very big strings that compose each subject. Either break up the string into the cores you have available, or have each core process a different subject. If you have an i7, thats already 8x faster than running it single core , and it's as simple as doing


#pragma omp parallel for
for (i=0;i<numberOfSubjects;i++)
processSubject(subject[i]);


There are other ways of doing it but I guess they're a bit harder than this. For example, you can use MPI to run it through multiple computers, say you have 10 computers at 2 cores each (normal school computers) that's 20 cores running your code
Frigo
Profile Joined August 2009
Hungary1023 Posts
November 11 2013 22:16 GMT
#7784
On November 12 2013 02:37 Manit0u wrote:
And remember, extends are evil. Interface inheritance > implementation inheritance.

components > delegation > mixins > interfaces > inheritance
http://www.fimfiction.net/user/Treasure_Chest
Fawkes
Profile Blog Joined May 2010
Canada1935 Posts
November 11 2013 22:25 GMT
#7785
Are there any visual editors out there that makes the creation of php forms easier?
Taeyeon ~ Jennie ~ Seulgi ~ Irene @Fawkes711
klo8
Profile Joined August 2010
Austria1960 Posts
Last Edited: 2013-11-11 22:50:20
November 11 2013 22:47 GMT
#7786
On November 12 2013 01:52 Yoshi- wrote:
Show nested quote +
On November 11 2013 07:30 sluggaslamoo wrote:

If you have any functions that are longer than 10 lines seriously have a look at them and see if you can't break them down. Most of my functions are 1-3 (ruby) lines long, this is due to functional programming though, I'd say for PHP they should float between 3 to 5 lines on average.


Yea that is bullshit
I all up for splitting code into smaller part, but saying that you should average between 3 to 5 lines is just ridiculous

I agree. Saying that 3-5 lines (or even 10 lines) per method should be your average doesn't even make much sense because it completely disregards how complicated the thing is the method does. You can't really do the A* algorithm in 10 lines and if you break it up into chunks of 10 LoC long methods, it would hurt readability more than it would help.

Also, in a lot of cases, more lines are actually more readable, especially in functional code where you might be tempted to do as much as you possibly can in one statement/expression, just because you can. (like chaining a map and a filter and a reduce in one line is cool when you're first learning it because you'd probably need at least 5-10 lines to do the same with loops, but IMO it hinders readability)
This post is clearly not a hurr, as you can see from the graph, the durr never intersects with the derp.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 11 2013 22:53 GMT
#7787
On November 12 2013 02:37 Manit0u wrote:
And remember, extends are evil. Interface inheritance > implementation inheritance.


Yes I remember that article, when I was a naive young child and all I did was Java I followed that mantra like a religion.

Then 2 years later after learning a lot more, I realised it was a pile of crap written by a guy who just wanted to make a name for himself His idea leads to re-writing the same code over and over again with overly complex inheritance hierarchies, it just doesn't suit real world applications.

A lot of the Java doctrines don't make a whole lot of sense, and is really just to get around the pitfalls of the language. Nevertheless, just because Java doesn't support implementation inheritance well doesn't mean we shouldn't use it. OO is about code re-use, and there is zero code re-use in interfaces.

Really we should never use interfaces, unless we explicitly need polymorphism and we need to branch out to more than one "Generalisation", e.g for combining like objects in a collection. I'd say always favour implementation inheritance over interface inheritance, but not more than one level. Favour composition over inheritance. Although Java could just have mixins or traits and then we wouldn't have to worry about any of this crap.

My favourite articles are the ones that start with "Why Java doesn't need X". Then proceeding to give denialistic reasons as to why X feature is such a "minor change at best" because Java can already do it by writing 100 lines more code. Yes Mr. Java expert, so can you tell me why my enterprise projects that are written in Java are 100x bigger than the (insert dynamic language here) projects that do the exact same thing? Oh I see, its a feature of Java.

They are right in a sense, Java doesn't need any more features, as long as you think writing boiler plate is the best thing since sliced bread.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-11-11 23:30:16
November 11 2013 23:13 GMT
#7788
On November 12 2013 07:47 klo8 wrote:
Show nested quote +
On November 12 2013 01:52 Yoshi- wrote:
On November 11 2013 07:30 sluggaslamoo wrote:

If you have any functions that are longer than 10 lines seriously have a look at them and see if you can't break them down. Most of my functions are 1-3 (ruby) lines long, this is due to functional programming though, I'd say for PHP they should float between 3 to 5 lines on average.


Yea that is bullshit
I all up for splitting code into smaller part, but saying that you should average between 3 to 5 lines is just ridiculous

I agree. Saying that 3-5 lines (or even 10 lines) per method should be your average doesn't even make much sense because it completely disregards how complicated the thing is the method does. You can't really do the A* algorithm in 10 lines and if you break it up into chunks of 10 LoC long methods, it would hurt readability more than it would help.

Also, in a lot of cases, more lines are actually more readable, especially in functional code where you might be tempted to do as much as you possibly can in one statement/expression, just because you can. (like chaining a map and a filter and a reduce in one line is cool when you're first learning it because you'd probably need at least 5-10 lines to do the same with loops, but IMO it hinders readability)


Functional programming is only hard to read when you don't understand it, otherwise its easier to read. Its almost like saying we shouldn't use object orientation because it makes the code more complicated than doing things in a structural (procedural) manner.

On November 12 2013 02:23 spinesheath wrote:
Breaking code up into smaller parts only makes sense if you can come up with good names for these parts. If you functions are small but their names don't clearly describe what they do, you made your code worse by splitting it up.


If you follow the proper principle of functional decomposition this will never happen.

On November 12 2013 01:52 Yoshi- wrote:
Show nested quote +
On November 11 2013 07:30 sluggaslamoo wrote:

If you have any functions that are longer than 10 lines seriously have a look at them and see if you can't break them down. Most of my functions are 1-3 (ruby) lines long, this is due to functional programming though, I'd say for PHP they should float between 3 to 5 lines on average.


Yea that is bullshit
I all up for splitting code into smaller part, but saying that you should average between 3 to 5 lines is just ridiculous


"I don't know how to do it, therefore its bullshit"

You guys aren't trying hard enough. I always check the commit log and whenever a developer writes a function that is more than 10 lines long I can almost always find a way to break it up into more re-useable functions or find a better way to write it, this then cascades down into being used into his other functions and before you know it I end up deleting a hundred lines of code.

Most people just don't know how to break things down efficiently. I see this problem in almost all projects I start work in, I can immediately see far better abstractions but its just not worth fixing it unless there is very high test coverage.

If I had some sort of way to calculate lines of code per method in any of my contract projects you would get an average of 3 lines per method. Most of my model methods are a single line long, my controller methods about 3-5 lines. It makes it extremely readable and maintainable.

D.R.Y my friend
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
KaiserJohan
Profile Joined May 2010
Sweden1808 Posts
November 11 2013 23:17 GMT
#7789
It feels like a natural progression for a programmer is to start in merry OOP-land and then as you grow slowly realise how ugly it is and transition into more functional languages and paradigms
England will fight to the last American
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-11-11 23:28:55
November 11 2013 23:22 GMT
#7790
On November 12 2013 07:16 Frigo wrote:
Show nested quote +
On November 12 2013 02:37 Manit0u wrote:
And remember, extends are evil. Interface inheritance > implementation inheritance.

components > delegation > mixins > interfaces > inheritance


mixins are really a form of inheritance that fulfills the role of components + delegation

Therefore if you have access to mixins you really aren't gonna use delegation, components or inheritance. While it is still possible to use, whenever I have used composition, delegation or inheritance in the past I always ended up deleting it later and just used a mixin.

I assume you meant components as in a library of functions, such as helpers. I definitely use a lot of composition for models but that is kind of a given.

Unless you meant components as in external libraries, though funnily enough, often they just require you to use a mixin.

Usually languages that support mixins have duck-typing making interfaces kind of redundant, you can still use them but only if you're a design nazi.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
November 12 2013 01:11 GMT
#7791
On November 12 2013 08:17 KaiserJohan wrote:
It feels like a natural progression for a programmer is to start in merry OOP-land and then as you grow slowly realise how ugly it is and transition into more functional languages and paradigms


Someone listens too much to Dijkstra and co.
Shikada
Profile Joined May 2012
Serbia976 Posts
November 12 2013 01:20 GMT
#7792
On November 12 2013 08:17 KaiserJohan wrote:
It feels like a natural progression for a programmer is to start in merry OOP-land and then as you grow slowly realise how ugly it is and transition into more functional languages and paradigms


It should be a natural progression to get at least interested in the functional style of programming, learn its advantages and disadvantages and then later use whichever style is superior to your task.

People disgruntled with the verbosity of Java will fall in love with dynamic languages, people that are more mathematically inclined love functional languages, but in the end, the best programmers choose their tools based on merits that are much less emotionally charged.
wherebugsgo
Profile Blog Joined February 2010
Japan10647 Posts
November 12 2013 02:12 GMT
#7793
On November 12 2013 08:13 sluggaslamoo wrote:
Show nested quote +
On November 12 2013 07:47 klo8 wrote:
On November 12 2013 01:52 Yoshi- wrote:
On November 11 2013 07:30 sluggaslamoo wrote:

If you have any functions that are longer than 10 lines seriously have a look at them and see if you can't break them down. Most of my functions are 1-3 (ruby) lines long, this is due to functional programming though, I'd say for PHP they should float between 3 to 5 lines on average.


Yea that is bullshit
I all up for splitting code into smaller part, but saying that you should average between 3 to 5 lines is just ridiculous

I agree. Saying that 3-5 lines (or even 10 lines) per method should be your average doesn't even make much sense because it completely disregards how complicated the thing is the method does. You can't really do the A* algorithm in 10 lines and if you break it up into chunks of 10 LoC long methods, it would hurt readability more than it would help.

Also, in a lot of cases, more lines are actually more readable, especially in functional code where you might be tempted to do as much as you possibly can in one statement/expression, just because you can. (like chaining a map and a filter and a reduce in one line is cool when you're first learning it because you'd probably need at least 5-10 lines to do the same with loops, but IMO it hinders readability)


Functional programming is only hard to read when you don't understand it, otherwise its easier to read. Its almost like saying we shouldn't use object orientation because it makes the code more complicated than doing things in a structural (procedural) manner.

Show nested quote +
On November 12 2013 02:23 spinesheath wrote:
Breaking code up into smaller parts only makes sense if you can come up with good names for these parts. If you functions are small but their names don't clearly describe what they do, you made your code worse by splitting it up.


If you follow the proper principle of functional decomposition this will never happen.

Show nested quote +
On November 12 2013 01:52 Yoshi- wrote:
On November 11 2013 07:30 sluggaslamoo wrote:

If you have any functions that are longer than 10 lines seriously have a look at them and see if you can't break them down. Most of my functions are 1-3 (ruby) lines long, this is due to functional programming though, I'd say for PHP they should float between 3 to 5 lines on average.


Yea that is bullshit
I all up for splitting code into smaller part, but saying that you should average between 3 to 5 lines is just ridiculous


"I don't know how to do it, therefore its bullshit"

You guys aren't trying hard enough. I always check the commit log and whenever a developer writes a function that is more than 10 lines long I can almost always find a way to break it up into more re-useable functions or find a better way to write it, this then cascades down into being used into his other functions and before you know it I end up deleting a hundred lines of code.

Most people just don't know how to break things down efficiently. I see this problem in almost all projects I start work in, I can immediately see far better abstractions but its just not worth fixing it unless there is very high test coverage.

If I had some sort of way to calculate lines of code per method in any of my contract projects you would get an average of 3 lines per method. Most of my model methods are a single line long, my controller methods about 3-5 lines. It makes it extremely readable and maintainable.

D.R.Y my friend


No offense, but you sound like a pain in the ass to work with. As other people have said, you can't just make the generalisation that all functions can be broken down into auxiliary functions of size X, or that even if they could, that it would necessarily be better. I can even think of examples right now that seem mathematically quite simple but are ugly as fuck if you try to decompose them too much. For example, writing a ray-object intersection test for a raytracer. Writing various prime factorization algorithms (e.g. Shanks or Dixon's). Writing anything with conditional cases in which calling auxiliary functions spreads the code too much-readability there comes from personal preference, really. If each auxiliary method is only one line or two lines long then you might as well leave it in the original function without separating it in the first place (since by making it auxiliary you need to define it somewhere else, adding lines and spreading out the code, making it more disorganised)

sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 12 2013 02:22 GMT
#7794
On November 12 2013 10:20 Shikada wrote:
Show nested quote +
On November 12 2013 08:17 KaiserJohan wrote:
It feels like a natural progression for a programmer is to start in merry OOP-land and then as you grow slowly realise how ugly it is and transition into more functional languages and paradigms


It should be a natural progression to get at least interested in the functional style of programming, learn its advantages and disadvantages and then later use whichever style is superior to your task.

People disgruntled with the verbosity of Java will fall in love with dynamic languages, people that are more mathematically inclined love functional languages, but in the end, the best programmers choose their tools based on merits that are much less emotionally charged.


I've realised that this only applies in theory.

If it was the case, everyone would be using Erlang for concurrency, and Smalltalk for object orientation. While Node and Ruby are the children of these languages respectively, most of the time languages are chosen not to fit the appropriate problem domain.

Given your principle, we should never have used Java/C++, ever. It should have been Smalltalk for business applications.

In reality there is no such thing as a toolbox of languages which you choose fit for the task. Programming languages are not cars. Its not like, oh this is an X problem domain I should use PHP, and for Y I should use Rails, and for Z I should use Java. It just doesn't work that way.

If you have the budget, and you fork out for the best developers and they will probably choose to write the app in Scala or Erlang or something. For a high-medium sized budget, Ruby/Node/Python, for a small budget Java/PHP.

In the end, there are languages that are just flat-out better than others in every conceivable way, and the only reason for not using them is because your developers don't know how to, or you can't afford developers that can. Hypothetically with an unlimited budget, there is never a time where Java would be the best choice.

I can only say different for AAA title games, but this has more to do with corporate dogma, just like how most corporations use Java/.NET for applications. Most indie games are not created using C++, hackathon winners are often in Javascript, Minecraft was created in Java but there was nothing stopping the developer from using JRuby and completing it in a much shorter time-frame. This never stopped a huge amount of people from buying and playing these games.

Technically AAA title games "should" be written in C++ in order to work on as low-spec machines as possible. However the irony is that because customer PC specs are so high now, we no longer bother to use the optimisations that C++ gives us because of development costs. In which case we may as well not be using C++ anyway.

Starcraft is a good example of this, it obviously has some very complex OO for its map-editor, it also uses garbage collection for its scripts, however in the past developers chose not to use OO or GC in AAA games because it would take more processing power.

----

I was never disgruntled with the verbosity of Java until I tried dynamic languages, I was never mathematically inclined but I love functional programming. Going back to Java is like going back to an old game you loved and realising its now unplayable. Keeping code concise is always going to be every programmers goal, I think the reason people stick with certain languages has more to do with the Peter Principle (generalised form of).

People often tell me how certain features are unnecessary and just make things more complicated, until I ask them to implement something which took them 30 lines, and then I show them an example in 2 lines, not to mention in a lot shorter timespan. You can imagine the cascade effect this would have going through an entire project.

I am even finding this even for myself. There are certain things I've seen developers do that are beyond the realm of my imagination (genetic algorithms for websites anyone?), they also program in much more difficult languages than I do. Some of them tell me they don't like Ruby but I can never understand why, but I'm sure its the same for me talking to a Java developer. Sure you can argue however you want about how your language does whatever you want, but only because you have never progressed to being able to solve more difficult problems.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
phar
Profile Joined August 2011
United States1080 Posts
November 12 2013 02:23 GMT
#7795
On November 12 2013 08:13 sluggaslamoo wrote:
"I don't know how to do it, therefore its bullshit"

You guys aren't trying hard enough. I always check the commit log and whenever a developer writes a function that is more than 10 lines long I can almost always find a way to break it up into more re-useable functions or find a better way to write it, this then cascades down into being used into his other functions and before you know it I end up deleting a hundred lines of code.

Most people just don't know how to break things down efficiently. I see this problem in almost all projects I start work in, I can immediately see far better abstractions but its just not worth fixing it unless there is very high test coverage.

If I had some sort of way to calculate lines of code per method in any of my contract projects you would get an average of 3 lines per method. Most of my model methods are a single line long, my controller methods about 3-5 lines. It makes it extremely readable and maintainable.

D.R.Y my friend


It could be that the things you are doing are quiet different. Not everything can be prettily broken up into short 3-5 line functions.
Who after all is today speaking about the destruction of the Armenians?
phar
Profile Joined August 2011
United States1080 Posts
November 12 2013 02:27 GMT
#7796
Oh wait nevermind you're this guy:

On April 30 2013 10:57 sluggaslamoo wrote:
As a whole, I'd say 95% of all developers in the world are absolutely atrocious because of the reason you gave. A very tiny fraction of developers actually know how to write good code and engage in computer science. I do not work with those kinds of developers and neither do my workmates because they are simply a waste of time.

I don't know why this is my loss, I get paid a substantially higher amount compared to your developers and get to work in a really good environment because of said reasons. Developers like yours would not even pass the interview of some of the companies I've worked in.
Who after all is today speaking about the destruction of the Armenians?
Cyx.
Profile Joined November 2010
Canada806 Posts
November 12 2013 02:41 GMT
#7797
On November 12 2013 11:27 phar wrote:
Oh wait nevermind you're this guy:

Show nested quote +
On April 30 2013 10:57 sluggaslamoo wrote:
As a whole, I'd say 95% of all developers in the world are absolutely atrocious because of the reason you gave. A very tiny fraction of developers actually know how to write good code and engage in computer science. I do not work with those kinds of developers and neither do my workmates because they are simply a waste of time.

I don't know why this is my loss, I get paid a substantially higher amount compared to your developers and get to work in a really good environment because of said reasons. Developers like yours would not even pass the interview of some of the companies I've worked in.


So did like three whole days of posts get burned out of this thread, or is that from somewhere else? Because I went looking for context on that quote and there is nothing for the day before that date to the day after that date in this thread... and now I feel like I missed a good flame war
phar
Profile Joined August 2011
United States1080 Posts
November 12 2013 02:54 GMT
#7798
On November 12 2013 11:41 Cyx. wrote:
Show nested quote +
On November 12 2013 11:27 phar wrote:
Oh wait nevermind you're this guy:

On April 30 2013 10:57 sluggaslamoo wrote:
As a whole, I'd say 95% of all developers in the world are absolutely atrocious because of the reason you gave. A very tiny fraction of developers actually know how to write good code and engage in computer science. I do not work with those kinds of developers and neither do my workmates because they are simply a waste of time.

I don't know why this is my loss, I get paid a substantially higher amount compared to your developers and get to work in a really good environment because of said reasons. Developers like yours would not even pass the interview of some of the companies I've worked in.


So did like three whole days of posts get burned out of this thread, or is that from somewhere else? Because I went looking for context on that quote and there is nothing for the day before that date to the day after that date in this thread... and now I feel like I missed a good flame war

Sorry, unrelated thread from awhile back. http://www.teamliquid.net/forum/viewmessage.php?topic_id=410026&currentpage=18#341
Who after all is today speaking about the destruction of the Armenians?
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-11-12 03:13:57
November 12 2013 03:04 GMT
#7799
On November 12 2013 11:12 wherebugsgo wrote:
Show nested quote +
On November 12 2013 08:13 sluggaslamoo wrote:
On November 12 2013 07:47 klo8 wrote:
On November 12 2013 01:52 Yoshi- wrote:
On November 11 2013 07:30 sluggaslamoo wrote:

If you have any functions that are longer than 10 lines seriously have a look at them and see if you can't break them down. Most of my functions are 1-3 (ruby) lines long, this is due to functional programming though, I'd say for PHP they should float between 3 to 5 lines on average.


Yea that is bullshit
I all up for splitting code into smaller part, but saying that you should average between 3 to 5 lines is just ridiculous

I agree. Saying that 3-5 lines (or even 10 lines) per method should be your average doesn't even make much sense because it completely disregards how complicated the thing is the method does. You can't really do the A* algorithm in 10 lines and if you break it up into chunks of 10 LoC long methods, it would hurt readability more than it would help.

Also, in a lot of cases, more lines are actually more readable, especially in functional code where you might be tempted to do as much as you possibly can in one statement/expression, just because you can. (like chaining a map and a filter and a reduce in one line is cool when you're first learning it because you'd probably need at least 5-10 lines to do the same with loops, but IMO it hinders readability)


Functional programming is only hard to read when you don't understand it, otherwise its easier to read. Its almost like saying we shouldn't use object orientation because it makes the code more complicated than doing things in a structural (procedural) manner.

On November 12 2013 02:23 spinesheath wrote:
Breaking code up into smaller parts only makes sense if you can come up with good names for these parts. If you functions are small but their names don't clearly describe what they do, you made your code worse by splitting it up.


If you follow the proper principle of functional decomposition this will never happen.

On November 12 2013 01:52 Yoshi- wrote:
On November 11 2013 07:30 sluggaslamoo wrote:

If you have any functions that are longer than 10 lines seriously have a look at them and see if you can't break them down. Most of my functions are 1-3 (ruby) lines long, this is due to functional programming though, I'd say for PHP they should float between 3 to 5 lines on average.


Yea that is bullshit
I all up for splitting code into smaller part, but saying that you should average between 3 to 5 lines is just ridiculous


"I don't know how to do it, therefore its bullshit"

You guys aren't trying hard enough. I always check the commit log and whenever a developer writes a function that is more than 10 lines long I can almost always find a way to break it up into more re-useable functions or find a better way to write it, this then cascades down into being used into his other functions and before you know it I end up deleting a hundred lines of code.

Most people just don't know how to break things down efficiently. I see this problem in almost all projects I start work in, I can immediately see far better abstractions but its just not worth fixing it unless there is very high test coverage.

If I had some sort of way to calculate lines of code per method in any of my contract projects you would get an average of 3 lines per method. Most of my model methods are a single line long, my controller methods about 3-5 lines. It makes it extremely readable and maintainable.

D.R.Y my friend


No offense, but you sound like a pain in the ass to work with. As other people have said, you can't just make the generalisation that all functions can be broken down into auxiliary functions of size X, or that even if they could, that it would necessarily be better. I can even think of examples right now that seem mathematically quite simple but are ugly as fuck if you try to decompose them too much. For example, writing a ray-object intersection test for a raytracer. Writing various prime factorization algorithms (e.g. Shanks or Dixon's). Writing anything with conditional cases in which calling auxiliary functions spreads the code too much-readability there comes from personal preference, really. If each auxiliary method is only one line or two lines long then you might as well leave it in the original function without separating it in the first place (since by making it auxiliary you need to define it somewhere else, adding lines and spreading out the code, making it more disorganised)



Who is more of a pain, someone who cleans up code, or someone who comes up with obscure examples to try to prove someone wrong?

I have never had anyone call me a pain for cleaning up their code, in fact they are often surprised and happy they learned something and I get thanked for it.

How many times are you going to use these algorithms (not to mention combinations of these) in a normal application, maybe... never?

One of the projects I am working on involve very very complex algorithms as it is a cost estimator for hvac systems. It generates every possible hvac system from a hundred different parts and estimates things like electricity consumption, pollution, etc, and ranks them on the basis of the best solution for particular requirements which also get factored into the calculation (size of building, etc). It then has a bunch of sorting/grouping algorithms because you get 1000+ results at a time, and you need something to help you sift through them. My model methods are mostly 1 line (even with complex calculations), and other files are maybe 3-5 lines?

Ill give a real example. A solution is a combination of a heating and cooling system, you have hundreds of each. Each system is a combination of a multitude of different parts, distribution, control and plant. You need to generate a system for every permutation of these parts, and then a solution for every permutation of these systems.

Think about how you would implement combining a list of all combinations of parts to form a system, and combining every single permutation of these systems into a solution with 3 lines per method.

For the sake of the example, because generating the systems is basically the exact same implementation as combining the systems together, just do the last bit.


def generate_solutions
all_possible_heating_systems.product(all_possible_cooling_systems).collect { |x, y|
HvacSolution.new(etc)
}.compact

Technically its a line long but lets say 3 lines

all_possible_X_systems is the same as above but the product of compatible plants, distributions and controls, takes about 3 lines of code max.


I can imagine a million developers write now writing a multitude of loop statements and if-statements inside a single method to do the same thing. Also is it really hard to read or "decomposed too much" like you mentioned?

If you are going to make the statement that you can't understand what it does, well would you say them same to a person who only understands procedural programming to your OO code? To anyone that is good at Ruby, they could tell you what it does in an instant, much faster than it would take to read through multitudes of loop statements.

This is no big deal either, its a very trivial example, I could give you a bunch more complicated examples where I am doing the complex math and processing and the code is very concise but I had to choose one that was general enough and doesn't give too much away.

Apart from the fact that I completely disagree and there is a way to make any algorithm much more concise (seen quick-sort written in one line?), and apart from the practicality of writing these yourself rather than just using a library, I'd have to say that my argument does not really apply to any of your examples.

In a normal project you aren't going to write a complex algorithm for every... single... method, how many times are you going to write raytrace and pathfinding algorithms? (honestly if you have to write an A* algorithm more than once in a project your doing it wrong), its obviously a damn guideline and not one that applies to a physicist working for NASA. Or you just completely misunderstood what I said.

Also tests are not methods or functions. Yes my test code is big, but it has nothing to do with what I said.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Zocat
Profile Joined April 2010
Germany2229 Posts
November 12 2013 04:25 GMT
#7800
On November 12 2013 12:04 sluggaslamoo wrote:
Ill give a real example. A solution is a combination of a heating and cooling system, you have hundreds of each. Each system is a combination of a multitude of different parts, distribution, control and plant. You need to generate a system for every permutation of these parts, and then a solution for every permutation of these systems.


lol
"permutation"
Prev 1 388 389 390 391 392 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 18h 17m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Serral 529
Lowko414
SteadfastSC 87
CosmosSc2 31
Codebar 1
StarCraft: Brood War
Shuttle 1992
Soma 1030
Mini 962
BeSt 483
Light 472
Larva 365
Leta 338
actioN 327
Snow 308
hero 228
[ Show more ]
Sharp 151
Dewaltoss 103
Sea.KH 47
Hyun 45
ToSsGirL 34
Sexy 27
Yoon 25
Trap 25
HiyA 22
Terrorterran 22
Classic 21
Free 19
Rock 14
ajuk12(nOOB) 12
zelot 12
soO 11
Sacsri 10
yabsab 10
Dota 2
Gorgc17294
qojqva1424
XaKoH 486
syndereN284
420jenkins194
XcaliburYe123
Heroes of the Storm
crisheroes443
Trikslyr71
Other Games
singsing2052
B2W.Neo1251
hiko1010
Liquid`RaSZi971
Pyrionflax284
RotterdaM230
FrodaN208
Liquid`VortiX173
ArmadaUGS156
TKL 155
mouzStarbuck126
Beastyqt0
Organizations
Counter-Strike
PGL24550
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• HerbMon 48
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV372
League of Legends
• Nemesis2120
• TFBlade1039
Other Games
• Shiphtur123
Upcoming Events
KCM Race Survival
18h 17m
IntoTheTV X SOOP
19h 17m
SHIN vs GuMiho
Clem vs Classic
OSC
1d 6h
WardiTV Invitational
1d 20h
GSL
1d 20h
Epic.LAN
1d 21h
Replay Cast
2 days
Sparkling Tuna Cup
2 days
Epic.LAN
2 days
AI Arena Tournament
3 days
[ Show More ]
Yamato Cup
3 days
Map Test Tournament
4 days
WardiTV Weekly
4 days
Replay Cast
5 days
Rogue vs Classic
Patches Events
5 days
PiGosaur Cup
6 days
Kung Fu Cup
6 days
Liquipedia Results

Completed

Proleague 2026-10-27
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

IPSL Winter 2026-27
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.