• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 23:29
CET 05:29
KST 13:29
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband Information Request Regarding Chinese Ladder SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
Which season is the best in ASL? [ASL20] Ask the mapmakers — Drop your questions BW General Discussion FlaSh's Valkyrie Copium BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread The Perfect Game Path of Exile Nintendo Switch Thread Should offensive tower rushing be viable in RTS games?
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1439 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
Poland17490 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
Portugal3241 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
PiGosaur Monday
01:00
#60
PiGStarcraft579
SteadfastSC135
CranKy Ducklings89
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft579
RuFF_SC2 155
SteadfastSC 135
Nathanias 86
StarCraft: Brood War
PianO 255
Noble 52
Icarus 9
Dota 2
monkeys_forever477
League of Legends
JimRising 700
Counter-Strike
Coldzera 1472
Other Games
summit1g13503
WinterStarcraft475
C9.Mang0360
ViBE158
Organizations
Other Games
gamesdonequick1106
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Hupsaiya 81
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki22
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo986
• Stunt378
Other Games
• Scarra1308
Upcoming Events
Wardi Open
7h 31m
StarCraft2.fi
12h 31m
Replay Cast
19h 31m
The PondCast
1d 5h
OSC
1d 11h
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 19h
Korean StarCraft League
2 days
CranKy Ducklings
3 days
SC Evo League
3 days
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
[ Show More ]
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
4 days
OSC
4 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
5 days
Wardi Open
5 days
StarCraft2.fi
5 days
Replay Cast
5 days
StarCraft2.fi
6 days
PiGosaur Monday
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
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 © 2025 TLnet. All Rights Reserved.