View Single Post
Old 10-26-2012, 07:59 AM   #238
shinigami052
Member
 
Join Date: Sep 2012
Drives: Stuff
Location: Hawaii
Posts: 22
Thanks: 1
Thanked 3 Times in 1 Post
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quote:
Originally Posted by GNS View Post
You're setting yourself up for multiple if-statements, or cascading
if-statements with this method of determining if a news_day is 'slow'
or 'fast'. *Since news_day is an object, you should be able to query
it and receive its current status with a single call, like so:



Also, why is the Turbo_BRZ an object iself? *It should be more
generic, so that you can pass an object around without having to name
it according to the news that it contains.

Based on all of the above changes, perhaps your code can be rewritten
as such (still a snippet of code). *I have written it sequentially,
instead of breaking things up into methods.




*(I still don't consider it perfect, it can be refined even further
and simplified even more). For example, autoreporter might be doing too much (things should be broken down into simple, focused and well defined operations).

The only real way to design a proper reporting system is to draw it out on a board (or use object design language to properly define objects and their relationships).

Bah.
Well the only way to really understand what each of us means is to fully flush everything out. My thinking was this:

news_Day is an object. Actually I'd probably put it as a variable in an object like Day and have an object inside called news with a variable of slow. isSlow would then be a boolean function that returns the value of the slow variable (basic OOP teaches to hide direct setting/getting of variables (information hiding) and to do it via functions). My personal convention is to use the "is" prefix for boolean variables and "get"/"set" for more complex variables. This helps keep things in line and at a quick glance I can tell that this function returns a bool and the variable is a bool.

Turbo_BRZ would be a variable. Since it seems to be used often, I'd make it to be a variable that could be used over multiple days instead of having to reiterate the same information over and over again (using proper code reuse techniques).

I guess it all comes down to personal preference but I tend to try to do things as compact as possible. I typically spend 90% of the time on a project pseudo coding and writing all the logic out first. Plus comments are always my best friend.

But anyway...

string Turbo_BRZ = "...";

Day Today = new Day();

/* set all the variables blah blah blah */

if(Today.news.isSlow()) report(Turbo_BRZ);

/*end of function*/
shinigami052 is offline   Reply With Quote