Click here to Skip to main content
15,906,094 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
kalberts12-Sep-19 13:37
kalberts12-Sep-19 13:37 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 13:40
mvahoney the codewitch12-Sep-19 13:40 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Alister Morton12-Sep-19 4:42
Alister Morton12-Sep-19 4:42 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
TrinityRaven12-Sep-19 4:47
TrinityRaven12-Sep-19 4:47 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 4:52
mvahoney the codewitch12-Sep-19 4:52 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
TrinityRaven12-Sep-19 5:23
TrinityRaven12-Sep-19 5:23 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 5:54
mvahoney the codewitch12-Sep-19 5:54 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
kalberts12-Sep-19 6:50
kalberts12-Sep-19 6:50 
TrinityRaven wrote:
Don't return null. Throw an exception instead.
Sure, if it really is an execption.

But I don't want to handle, say, a person who has no middle name as an exception just because his middle name is null. Or a person without a spouse, or without children.

I can guess your reply: The middle name should be a zero lenght string, not null!
In some cases, a zero-size value may be conceptually correct. Far from always. There is a semantic difference between something being there, regardless of size, and something not being there. You easily end up with testing on nonzero size rather than null, which may in some contexts be both confusing and give more complex code. And it might require more data space.

I guess that you still accept null checks in loops and list traversals, as long as as no function calls are involved: "while (nextobject != null) {process it and determine the next object}" is perfectly fine ... until "determine the next object" becomes so complex that you factor it out as a function. By your rule, the while condition can be dropped; you will threat the end of the list as something exceptional that requires exception handling.

But it isn't "exceptional" to reach the end of a list in list traversal! If you do not process all elements but factor out the code that decides which elements to skip, that doesn't make the end of the list more exceptional.

I started learing programming when access to computer resources were scarce. Maybe that was one reason for why many of the first hand-ins were to be made in pseudocode: somewhat formalized English, but remote from coding syntax. Actually, if we got even close to a programming language syntax, the professor used his red pen: Why do you restrict it this way? Is there, or isn't there, a semantic difference between this kind of value and that kind? Is it appropriate to add #apples to #oranges here - you tell that there isn't?

I like pseudocode. It relieves you from language syntax, lets you describe the problem solution at a logical level. If I had it my way, every software design should include a documentation of the solution logic in a form of pseudocode completely removed from any programming language. It should be equally valid if it was decided to re-implement the C++ system i Fortran, or Visual Basic or Erlang or APL. Even if the system is never reimplemented in another language, I think that kind of documentation would improve code quality, by focusing on the problem solution rather on syntax details.
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
TrinityRaven12-Sep-19 7:46
TrinityRaven12-Sep-19 7:46 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
kalberts12-Sep-19 10:13
kalberts12-Sep-19 10:13 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Bruce Greene12-Sep-19 4:51
Bruce Greene12-Sep-19 4:51 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Ira Greenstein12-Sep-19 5:07
Ira Greenstein12-Sep-19 5:07 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
kalberts12-Sep-19 6:52
kalberts12-Sep-19 6:52 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Ira Greenstein12-Sep-19 8:11
Ira Greenstein12-Sep-19 8:11 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Roger House12-Sep-19 8:05
Roger House12-Sep-19 8:05 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 8:07
mvahoney the codewitch12-Sep-19 8:07 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
kalberts12-Sep-19 9:40
kalberts12-Sep-19 9:40 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
firegryphon12-Sep-19 9:26
firegryphon12-Sep-19 9:26 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Dan Begent16-Sep-19 18:41
Dan Begent16-Sep-19 18:41 
GeneralMs. Monopoly: new board game that gives more money to women players that to men Pin
Daniel Pfeffer11-Sep-19 5:10
professionalDaniel Pfeffer11-Sep-19 5:10 
GeneralRe: Ms. Monopoly: new board game that gives more money to women players that to men Pin
PeejayAdams11-Sep-19 5:30
PeejayAdams11-Sep-19 5:30 
GeneralRe: Ms. Monopoly: new board game that gives more money to women players that to men Pin
  Forogar  11-Sep-19 7:26
professional  Forogar  11-Sep-19 7:26 
GeneralRe: Ms. Monopoly: new board game that gives more money to women players that to men Pin
Dan Neely12-Sep-19 2:43
Dan Neely12-Sep-19 2:43 
GeneralRe: Ms. Monopoly: new board game that gives more money to women players that to men PinPopular
Sander Rossel11-Sep-19 5:49
professionalSander Rossel11-Sep-19 5:49 
GeneralRe: Ms. Monopoly: new board game that gives more money to women players that to men Pin
raddevus11-Sep-19 7:22
mvaraddevus11-Sep-19 7:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.