• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 19:57
CEST 01:57
KST 08:57
  • 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
Tournament Spotlight: FEL Cracow 20259Power Rank - Esports World Cup 202577RSL Season 1 - Final Week9[ASL19] Finals Recap: Standing Tall15HomeStory Cup 27 - Info & Preview18
Community News
[BSL 2025] H2 - Team Wars, Weeklies & SB Ladder0EWC 2025 - Replay Pack1Google Play ASL (Season 20) Announced26BSL Team Wars - Bonyth, Dewalt, Hawk & Sziky teams10Weekly Cups (July 14-20): Final Check-up0
StarCraft 2
General
#1: Maru - Greatest Players of All Time EWC 2025 - Replay Pack Tournament Spotlight: FEL Cracow 2025 Power Rank - Esports World Cup 2025 I offer completely free coaching services
Tourneys
FEL Cracov 2025 (July 27) - $10,000 live event Esports World Cup 2025 $25,000 Streamerzone StarCraft Pro Series announced $5,000 WardiTV Summer Championship 2025 WardiTV Mondays
Strategy
How did i lose this ZvP, whats the proper response
Custom Maps
External Content
Mutation # 484 Magnetic Pull Mutation #239 Bad Weather Mutation # 483 Kill Bot Wars Mutation # 482 Wheel of Misfortune
Brood War
General
BEST RECOVERY EXPERTS FOR BITCOIN,CRYPTO,USDT HIRE Google Play ASL (Season 20) Announced [BSL 2025] H2 - Team Wars, Weeklies & SB Ladder [Update] ShieldBattery: 2025 Redesign Dewalt's Show Matches in China
Tourneys
[Megathread] Daily Proleagues [BSL20] Non-Korean Championship 4x BSL + 4x China CSL Xiamen International Invitational [CSLPRO] It's CSLAN Season! - Last Chance
Strategy
Simple Questions, Simple Answers [G] Mineral Boosting Does 1 second matter in StarCraft?
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Total Annihilation Server - TAForever [MMORPG] Tree of Savior (Successor of Ragnarok) Path of Exile
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
UK Politics Mega-thread US Politics Mega-thread Stop Killing Games - European Citizens Initiative Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread [\m/] Heavy Metal Thread Movie Discussion! [Manga] One Piece Korean Music Discussion
Sports
2024 - 2025 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
World Cup 2022
Tech Support
Installation of Windows 10 suck at "just a moment" Computer Build, Upgrade & Buying Resource Thread
TL Community
TeamLiquid Team Shirt On Sale The Automated Ban List
Blogs
Ping To Win? Pings And Their…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Socialism Anyone?
GreenHorizons
Eight Anniversary as a TL…
Mizenhauer
Customize Sidebar...

Website Feedback

Closed Threads



Active: 637 users

The Big Programming Thread - Page 563

Forum Index > General Forum
Post a Reply
Prev 1 561 562 563 564 565 1031 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
Poland17255 Posts
Last Edited: 2015-01-10 00:00:39
January 09 2015 23:59 GMT
#11241
There's real code and academic code. If you had all the time in the world then sure, make your code as beautiful as you want, add any amount of abstraction you want etc. In reality, you get to work on some project, most likely you join it in the middle or near the end of development cycle. You have a deadline that doesn't allow you to do much (Unit testing? You're joking, right?). What counts there is that you look at a single piece of code from the framework you haven't seen before and you must know what to do with it. It's all that matters, you don't have 2 days to spare figuring out how the entire framework is built and what's going on under the hood, you must do x in feature y by the end of date z - that's all that concerns you.

In such situations you don't care how badly the code is formatted, if it's commented or not. All you care about is if you see a small piece of code taken from a bigger project and with just this small piece how fast can you either alter it or use it to get specific result in your timeframe.

In the beginning I was a big proponent of all the "clean code", SOLID and all that stuff. Right now I'm in favor of duct tape programming. But I never forget about the past, so if I ever find a badly formatted or badly written code and I have a minute or two to spare I'll make even a small piece of it better. This way, as I work through numerous tasks I'm not only introducing new code that's "good enough" in my eyes, I slowly make improvements to the old code to meet the same standards.

On another note, do you also hate it when you encounter this?


catch (Exception $ex) {
// do nothing
}
Time is precious. Waste it wisely.
Xyik
Profile Blog Joined November 2009
Canada728 Posts
January 10 2015 00:21 GMT
#11242
I feel like people who speak of 'elegant' code and 'beautiful' code have not had to deal with large-scale development on a real production code base ... good code is : efficient, re-usable, maintainable and easy to understand, thats it. No tricks, no cleverness, no abstract concepts that make good code.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2015-01-10 01:27:31
January 10 2015 01:27 GMT
#11243
is there something to be said about completely abstract code
beyond vacuous hogwash and tired truisms?

i think not!
conspired against by a confederacy of dunces.
Manit0u
Profile Blog Joined August 2004
Poland17255 Posts
January 10 2015 02:27 GMT
#11244
I guess it depends on what do you consider an abstract code. If you use a layer of abstraction to make it more readable and easier to use then by all means do so, but if you start introducing multiple layers of abstraction just for the sake of making it abstract you're most likely doing something wrong.

I'm not the most experienced developer around so I might be wrong on this though.
Time is precious. Waste it wisely.
LaNague
Profile Blog Joined April 2010
Germany9118 Posts
Last Edited: 2015-01-10 02:34:55
January 10 2015 02:33 GMT
#11245
On January 09 2015 08:53 darkness wrote:
Show nested quote +
On January 08 2015 10:12 LaNague wrote:
I thinkgood programming is something similar to good painting.


You have to have a brain for it and you have to practice technique.
No matter how much i practiced for my stupid art aclasses in school, in 12 years i did not produce a single good looking picture.
And similar, some people in my university are incapable of producing good code, their brain isnt made for it.

But university CS degrees arent about programming, you learn mostly other stuff and have some basic programming classes.
Same as an art degree is probably not painting things all week (i think?).



hey what would you recommend to programm a little 3d video game? i heared c++ is the best for this?

what libaries would i need besides opengl? i would need something to load files with sound, images, 3d models etc. Which SDK can offer all that. I am looking for something that makes life easy. But i want to go the professional way




that totally depends.
If you just want to get it over with and design your game and dont care that you cant really tune everything, then Unity or a similar engine. It can also be used in C# for example.

If you are in it for the experience or need something custom, then you need C++ with either directX or openGL.


Also, there are shades between those 2 options, but im not a game programmer so i dont know whats hot right now regarding that.


Come on, this is bullshit. You should probably define what you mean by good code, but if you mean readable, then all it takes is to read the book 'Clean Code' by Robert Martin. I don't think one has to have an excellent brain, it is just a discipline.





http://www.eis.mdx.ac.uk/research/PhDArea/saeed/paper1.pdf


here, bullshit right back to you
nunez
Profile Blog Joined February 2011
Norway4003 Posts
January 10 2015 02:50 GMT
#11246
On January 10 2015 11:27 Manit0u wrote:
I guess it depends on what do you consider an abstract code. If you use a layer of abstraction to make it more readable and easier to use then by all means do so, but if you start introducing multiple layers of abstraction just for the sake of making it abstract you're most likely doing something wrong.

I'm not the most experienced developer around so I might be wrong on this though.

literally abstract code.

existing in thought or as an idea but not having a physical or concrete existence.
conspired against by a confederacy of dunces.
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2015-01-10 03:20:46
January 10 2015 03:10 GMT
#11247
On January 10 2015 05:41 spinesheath wrote:
Show nested quote +
On January 10 2015 05:25 ComaDose wrote:
but what if you can make it work faster with a more convoluted method? good code is also a function of the requirements and weighted criteria.

Then there's a good chance I'll scold you for thinking about optimization before profiling. Also then there likely is a way to make it faster without convoluting the code.

Hmm. No? There are plenty of examples of more complex algorithms (more "convoluted" if you will, and definitely harder to read) that solve the same problem as the clean naive understandable way but with better complexity (so, faster for large enough instances). Going from O(n^3) to O(n^2.81) is sometimes worth the work and the harder readability.

I think ComaDose was right in that what makes the code good largely depends on what it needs to achieve in which circumstances.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
January 10 2015 09:40 GMT
#11248
On January 10 2015 08:59 Manit0u wrote:
On another note, do you also hate it when you encounter this?


catch (Exception $ex) {
// do nothing
}

It's not as bad as the same thing without any comment at all. In your case, at least there's hope that someone spent a moment to consider if this piece of code works properly. Still, they likely eat a whole suite of exceptions that they didn't mean to eat.

On January 10 2015 12:10 ZenithM wrote:
Show nested quote +
On January 10 2015 05:41 spinesheath wrote:
On January 10 2015 05:25 ComaDose wrote:
but what if you can make it work faster with a more convoluted method? good code is also a function of the requirements and weighted criteria.

Then there's a good chance I'll scold you for thinking about optimization before profiling. Also then there likely is a way to make it faster without convoluting the code.

Hmm. No? There are plenty of examples of more complex algorithms (more "convoluted" if you will, and definitely harder to read) that solve the same problem as the clean naive understandable way but with better complexity (so, faster for large enough instances). Going from O(n^3) to O(n^2.81) is sometimes worth the work and the harder readability.

I think ComaDose was right in that what makes the code good largely depends on what it needs to achieve in which circumstances.

Again, a performance gain only ever matters if you 1) have a performance problem and 2) profiled the program to find the critical code. If you get a piece of code from O(n^10) to O(log(n)) but that code never was responsible for more than 1% of the runtime, you wasted development time and possibly readability.
Second part of the issue is that only a very small part of your code will ever be performance critical. The vast majority of it has next to no effect on performance. Obviously there may be a case where you have to sacrifice readability for performance, but in the grand scheme of things these parts are drowned by all the code that isn't performance critical. I'm not going to change the my opinion of what good code is just because <1% of a code base has a chance to require special treatment.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17255 Posts
January 10 2015 09:59 GMT
#11249
On January 10 2015 18:40 spinesheath wrote:
Show nested quote +
On January 10 2015 08:59 Manit0u wrote:
On another note, do you also hate it when you encounter this?


catch (Exception $ex) {
// do nothing
}

It's not as bad as the same thing without any comment at all. In your case, at least there's hope that someone spent a moment to consider if this piece of code works properly. Still, they likely eat a whole suite of exceptions that they didn't mean to eat.


The comment was added by me. I see catch (Exception $ex) {} on a daily basis... Annoys the hell out of me.
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-01-10 11:25:36
January 10 2015 11:24 GMT
#11250
On January 10 2015 18:59 Manit0u wrote:
Show nested quote +
On January 10 2015 18:40 spinesheath wrote:
On January 10 2015 08:59 Manit0u wrote:
On another note, do you also hate it when you encounter this?


catch (Exception $ex) {
// do nothing
}

It's not as bad as the same thing without any comment at all. In your case, at least there's hope that someone spent a moment to consider if this piece of code works properly. Still, they likely eat a whole suite of exceptions that they didn't mean to eat.


The comment was added by me. I see catch (Exception $ex) {} on a daily basis... Annoys the hell out of me.


Assuming that this isn't an example where one was just too lazy to check the error condition and instead lets it throw an exception...

I've iterated to logging something out in these cases if I'm going to catch instead of the do nothing comment...usually wrapped in a debug enabled statement so it normally doesn't do anything. It's equivalent in cases where the logger is not set to debug, and _way_ better when you know to know why you are getting into that exception block.

On January 10 2015 08:59 Manit0u wrote:
There's real code and academic code. If you had all the time in the world then sure, make your code as beautiful as you want, add any amount of abstraction you want etc. In reality, you get to work on some project, most likely you join it in the middle or near the end of development cycle. You have a deadline that doesn't allow you to do much (Unit testing? You're joking, right?). What counts there is that you look at a single piece of code from the framework you haven't seen before and you must know what to do with it. It's all that matters, you don't have 2 days to spare figuring out how the entire framework is built and what's going on under the hood, you must do x in feature y by the end of date z - that's all that concerns you.

In such situations you don't care how badly the code is formatted, if it's commented or not. All you care about is if you see a small piece of code taken from a bigger project and with just this small piece how fast can you either alter it or use it to get specific result in your timeframe.

In the beginning I was a big proponent of all the "clean code", SOLID and all that stuff. Right now I'm in favor of duct tape programming. But I never forget about the past, so if I ever find a badly formatted or badly written code and I have a minute or two to spare I'll make even a small piece of it better. This way, as I work through numerous tasks I'm not only introducing new code that's "good enough" in my eyes, I slowly make improvements to the old code to meet the same standards.


There is a lot of truth to this... I've seen it practiced and even for myself usually always prefer the duct tape solution even if its not the one chosen.

I've also seen what 15 years of duct tape solutions can do to a code base, especially when developers are coming and going. Some of them were probably good at the boy scout method (leaving it better than you found it ) type of approach that you mention. Others struggle... making changes is extremely difficult because being able to read the code and comprehend the effect of change you are introducing is either extremely time consuming or too difficult without giving up and pitching a rewrite.

After years of "duct taping", I've had the fortune over the past couple years of leading the new projects at our company while being given the time to try to write "clean code" and focusing on automated testing. Between the technical debt, slower velocity due to modifying a 15 yr old code base, and lack of automated regression testing... it's not hard to understand why management sees value in allowing for us to "try to get it right this time".

There is obviously a lot of value in taking the time to structure your code correctly and adding automated testing of some sort. I'm really curious to see whether it ends up being worth it and actually can lead to continued velocity over the years.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
January 10 2015 11:32 GMT
#11251
On January 10 2015 20:24 berated- wrote:
Show nested quote +
On January 10 2015 18:59 Manit0u wrote:
On January 10 2015 18:40 spinesheath wrote:
On January 10 2015 08:59 Manit0u wrote:
On another note, do you also hate it when you encounter this?


catch (Exception $ex) {
// do nothing
}

It's not as bad as the same thing without any comment at all. In your case, at least there's hope that someone spent a moment to consider if this piece of code works properly. Still, they likely eat a whole suite of exceptions that they didn't mean to eat.


The comment was added by me. I see catch (Exception $ex) {} on a daily basis... Annoys the hell out of me.


Assuming that this isn't an example where one was just too lazy to check the error condition and instead lets it throw an exception...

I've iterated to logging something out in these cases if I'm going to catch instead of the do nothing comment...usually wrapped in a debug enabled statement so it normally doesn't do anything. It's equivalent in cases where the logger is not set to debug, and _way_ better when you know to know why you are getting into that exception block.

Show nested quote +
On January 10 2015 08:59 Manit0u wrote:
There's real code and academic code. If you had all the time in the world then sure, make your code as beautiful as you want, add any amount of abstraction you want etc. In reality, you get to work on some project, most likely you join it in the middle or near the end of development cycle. You have a deadline that doesn't allow you to do much (Unit testing? You're joking, right?). What counts there is that you look at a single piece of code from the framework you haven't seen before and you must know what to do with it. It's all that matters, you don't have 2 days to spare figuring out how the entire framework is built and what's going on under the hood, you must do x in feature y by the end of date z - that's all that concerns you.

In such situations you don't care how badly the code is formatted, if it's commented or not. All you care about is if you see a small piece of code taken from a bigger project and with just this small piece how fast can you either alter it or use it to get specific result in your timeframe.

In the beginning I was a big proponent of all the "clean code", SOLID and all that stuff. Right now I'm in favor of duct tape programming. But I never forget about the past, so if I ever find a badly formatted or badly written code and I have a minute or two to spare I'll make even a small piece of it better. This way, as I work through numerous tasks I'm not only introducing new code that's "good enough" in my eyes, I slowly make improvements to the old code to meet the same standards.


There is a lot of truth to this... I've seen it practiced and even for myself usually always prefer the duct tape solution even if its not the one chosen.

I've also seen what 15 years of duct tape solutions can do to a code base, especially when developers are coming and going. Some of them were probably good at the boy scout method (leaving it better than you found it ) type of approach that you mention. Others struggle... making changes is extremely difficult because being able to read the code and comprehend the effect of change you are introducing is either extremely time consuming or too difficult without giving up and pitching a rewrite.

After years of "duct taping", I've had the fortune over the past couple years of leading the new projects at our company while being given the time to try to write "clean code" and focusing on automated testing. Between the technical debt, slower velocity due to modifying a 15 yr old code base, and lack of automated regression testing... it's not hard to understand why management sees value in allowing for us to "try to get it right this time".

There is obviously a lot of value in taking the time to structure your code correctly and adding automated testing of some sort. I'm really curious to see whether it ends up being worth it and actually can lead to continued velocity over the years.

they should include writing clean code as a class in schools, reading others code without an explanation is just imposable
The harder it becomes, the more you should focus on the basics.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
January 11 2015 16:58 GMT
#11252
Is anyone here a game developer? What's the excuse of companies like Blizzard not to utilise 4+ cores CPU?
bangsholt
Profile Joined June 2011
Denmark138 Posts
January 11 2015 17:34 GMT
#11253
Their engines were written when dual core was new / There's not enough gain to go to 4+ cores?
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
January 11 2015 17:38 GMT
#11254
On January 12 2015 01:58 darkness wrote:
Is anyone here a game developer? What's the excuse of companies like Blizzard not to utilise 4+ cores CPU?

It won't increase their sales but increases development costs.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17255 Posts
Last Edited: 2015-01-11 18:45:51
January 11 2015 18:45 GMT
#11255
Fun thing regarding game development and optimization:

[image loading]
[image loading]
Time is precious. Waste it wisely.
LaNague
Profile Blog Joined April 2010
Germany9118 Posts
Last Edited: 2015-01-11 20:41:02
January 11 2015 20:39 GMT
#11256
On January 12 2015 01:58 darkness wrote:
Is anyone here a game developer? What's the excuse of companies like Blizzard not to utilise 4+ cores CPU?




Its difficult to make your game scale with as many cores as are available, really really difficult.
Most devs go with as many fixed cores as they can easily develop for


With fixed cores you can for example make parts of the game run on different cores, like sound, physics, main game.
But for scalable cores you want all parts run on all cores, so first you need to develop your software in a way that parts can be run independandly of other parts in resources and in time.
And then you need to develop a scheduler who assigns independent work to all cores, preferrably guessing which work needs to be done in the future and assign this to idle cores.



This is because when using cores, you have to synchronize them in some way, you cant just run 25% of all work on all 4 cores because in the end programs have a sequence of commands that are run one after the other.
This synchronizing, when done wrong, can either lock things up or make them run very slowly(cores withing on other cores to finish and if sone in a circle everything locks up), or in other cases produce wrong results when 2 cores access to same resource at the same time.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
January 11 2015 21:37 GMT
#11257
On January 12 2015 05:39 LaNague wrote:
Show nested quote +
On January 12 2015 01:58 darkness wrote:
Is anyone here a game developer? What's the excuse of companies like Blizzard not to utilise 4+ cores CPU?

Its difficult to make your game scale with as many cores as are available, really really difficult.
Most devs go with as many fixed cores as they can easily develop for

Actually it's pretty easy to scale with a flexible number of cores as long as you do the hard part, which is designing your algorithm in a way that allows the bottleneck to be split up into a large number of independent tasks. Once you have an algorithm of the form
foreach(task in independentTasks) { task.Execute(); }
you can pick a multithreading framework of your choice, tell it to execute the loop in parallel, and it will distribute the load dynamically. No need to reinvent anything here.

The hard part is transforming the algorithm at the performance bottleneck. I have no idea what exactly the bottleneck is in Blizzard games, so I can't really tell just how hard it would be.

Usually the transformation comes with some overhead, so you need to run a bunch of performance tests on different numbers of cores and potentially come up with a way to switch to the sequential version of the algorithm in case you don't have enough cores to make the overhead worth it. That part is not very hard, but it's a lot of work.

But in the end it really is just too much work and thus too expensive for very little monetary gain.
If you have a good reason to disagree with the above, please tell me. Thank you.
Count9
Profile Blog Joined May 2009
China10928 Posts
January 11 2015 21:48 GMT
#11258
On January 12 2015 06:37 spinesheath wrote:
Show nested quote +
On January 12 2015 05:39 LaNague wrote:
On January 12 2015 01:58 darkness wrote:
Is anyone here a game developer? What's the excuse of companies like Blizzard not to utilise 4+ cores CPU?

Its difficult to make your game scale with as many cores as are available, really really difficult.
Most devs go with as many fixed cores as they can easily develop for

Actually it's pretty easy to scale with a flexible number of cores as long as you do the hard part, which is designing your algorithm in a way that allows the bottleneck to be split up into a large number of independent tasks. Once you have an algorithm of the form
foreach(task in independentTasks) { task.Execute(); }
you can pick a multithreading framework of your choice, tell it to execute the loop in parallel, and it will distribute the load dynamically. No need to reinvent anything here.

The hard part is transforming the algorithm at the performance bottleneck. I have no idea what exactly the bottleneck is in Blizzard games, so I can't really tell just how hard it would be.

Usually the transformation comes with some overhead, so you need to run a bunch of performance tests on different numbers of cores and potentially come up with a way to switch to the sequential version of the algorithm in case you don't have enough cores to make the overhead worth it. That part is not very hard, but it's a lot of work.

But in the end it really is just too much work and thus too expensive for very little monetary gain.

Yeah, essentially the game engine itself needs to be built for multi-threading from the ground up with all the associated overhead, which is substantial, figured out ahead of time. There's a reason the ratio of number of game engine developers vs number of game developers is at least 1:1000+; it's not something a kid straight out of college can do, or something you ship off to India and have them figure it out.

Sure, even without the engine fundamentally being multi-threaded you can always multi-thread afterwards, but that leads to exactly where we are now where 1 core does a huge majority of the work and the other cores still do a work but not nearly enough.

Game development is not a glamorous position (in terms of pay) and you need very talented engineers and time to figure out concurrency for something as complicated as a game engine.
Ben...
Profile Joined January 2011
Canada3485 Posts
January 11 2015 22:07 GMT
#11259
On January 10 2015 20:32 sabas123 wrote:
Show nested quote +
On January 10 2015 20:24 berated- wrote:
On January 10 2015 18:59 Manit0u wrote:
On January 10 2015 18:40 spinesheath wrote:
On January 10 2015 08:59 Manit0u wrote:
On another note, do you also hate it when you encounter this?


catch (Exception $ex) {
// do nothing
}

It's not as bad as the same thing without any comment at all. In your case, at least there's hope that someone spent a moment to consider if this piece of code works properly. Still, they likely eat a whole suite of exceptions that they didn't mean to eat.


The comment was added by me. I see catch (Exception $ex) {} on a daily basis... Annoys the hell out of me.


Assuming that this isn't an example where one was just too lazy to check the error condition and instead lets it throw an exception...

I've iterated to logging something out in these cases if I'm going to catch instead of the do nothing comment...usually wrapped in a debug enabled statement so it normally doesn't do anything. It's equivalent in cases where the logger is not set to debug, and _way_ better when you know to know why you are getting into that exception block.

On January 10 2015 08:59 Manit0u wrote:
There's real code and academic code. If you had all the time in the world then sure, make your code as beautiful as you want, add any amount of abstraction you want etc. In reality, you get to work on some project, most likely you join it in the middle or near the end of development cycle. You have a deadline that doesn't allow you to do much (Unit testing? You're joking, right?). What counts there is that you look at a single piece of code from the framework you haven't seen before and you must know what to do with it. It's all that matters, you don't have 2 days to spare figuring out how the entire framework is built and what's going on under the hood, you must do x in feature y by the end of date z - that's all that concerns you.

In such situations you don't care how badly the code is formatted, if it's commented or not. All you care about is if you see a small piece of code taken from a bigger project and with just this small piece how fast can you either alter it or use it to get specific result in your timeframe.

In the beginning I was a big proponent of all the "clean code", SOLID and all that stuff. Right now I'm in favor of duct tape programming. But I never forget about the past, so if I ever find a badly formatted or badly written code and I have a minute or two to spare I'll make even a small piece of it better. This way, as I work through numerous tasks I'm not only introducing new code that's "good enough" in my eyes, I slowly make improvements to the old code to meet the same standards.


There is a lot of truth to this... I've seen it practiced and even for myself usually always prefer the duct tape solution even if its not the one chosen.

I've also seen what 15 years of duct tape solutions can do to a code base, especially when developers are coming and going. Some of them were probably good at the boy scout method (leaving it better than you found it ) type of approach that you mention. Others struggle... making changes is extremely difficult because being able to read the code and comprehend the effect of change you are introducing is either extremely time consuming or too difficult without giving up and pitching a rewrite.

After years of "duct taping", I've had the fortune over the past couple years of leading the new projects at our company while being given the time to try to write "clean code" and focusing on automated testing. Between the technical debt, slower velocity due to modifying a 15 yr old code base, and lack of automated regression testing... it's not hard to understand why management sees value in allowing for us to "try to get it right this time".

There is obviously a lot of value in taking the time to structure your code correctly and adding automated testing of some sort. I'm really curious to see whether it ends up being worth it and actually can lead to continued velocity over the years.

they should include writing clean code as a class in schools, reading others code without an explanation is just imposable

It's not so much one class that teaches it, but enforcement of good code formatting/styling across all classes. Most universities have a "Programming Practices"-type class, but it can only do so much. At mine, that class was in second year and was mandatory, but by third year, most people were back to old habits and submitting mostly uncommented, awfully formatted nightmares outside of cases where it was required by the class (software engineering class, etc). Of the classes I took, most of the upper year classes asked for commented code, but outside of my systems programming class, there seldom were style/formatting guides used or enforced. It basically seems like a case of people not putting any thought into making actual clean, readable code unless there is incentive to do so.
"Cliiiiiiiiiiiiiiiiide" -Tastosis
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
January 11 2015 22:26 GMT
#11260
--- Nuked ---
Prev 1 561 562 563 564 565 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 11h 3m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 172
Ketroc 38
StarCraft: Brood War
NaDa 52
MaD[AoV]19
Dota 2
capcasts410
League of Legends
Grubby4748
febbydoto20
Counter-Strike
Fnx 2317
fl0m2106
Stewie2K913
flusha379
Super Smash Bros
hungrybox3444
Mew2King1256
AZ_Axe390
Heroes of the Storm
Khaldor230
Other Games
tarik_tv21770
summit1g15354
gofns9771
JimRising 621
ROOTCatZ307
Maynarde164
Organizations
Other Games
gamesdonequick3098
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• davetesta115
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki16
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Stormgate
• mYiSmile10
League of Legends
• Doublelift6703
Other Games
• Scarra2248
• imaqtpie1565
Upcoming Events
Wardi Open
11h 3m
Sparkling Tuna Cup
1d 10h
WardiTV European League
1d 16h
Online Event
1d 17h
uThermal 2v2 Circuit
2 days
The PondCast
3 days
Replay Cast
4 days
Korean StarCraft League
5 days
CranKy Ducklings
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

CSLPRO Last Chance 2025
Esports World Cup 2025
Murky Cup #2

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL 20 Non-Korean Championship
BSL 20 Team Wars
CC Div. A S7
Underdog Cup #2
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25

Upcoming

ASL Season 20: Qualifier #1
ASL Season 20: Qualifier #2
ASL Season 20
CSLPRO Chat StarLAN 3
BSL Season 21
RSL Revival: Season 2
Maestros of the Game
SEL Season 2 Championship
WardiTV Summer 2025
uThermal 2v2 Main Event
HCC Europe
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
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.