Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3
This is the forum to discuss the Wrox book Beginning C# 3.0 : An Introduction to Object Oriented Programming by Jack Purdum; ISBN: 9780470261293
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 17th, 2011, 10:19 AM
Registered User
 
Join Date: Jul 2011
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default Do I need to understand every algorithm?

Hi,

I'm really enjoying the book!

My current chapter is class design and how to call class methods from the Main program. The class I created calculates if the year entered is a leap year and the date Easter will fall on. The method algorithm used for leap years I can understand: if the year % 4 is 0 and year % 100 is not 0 or year % 400 is 0 return 1.


Code:
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                return 1; // year is a leap year
            else
                return 0; // nope

However the Algorithm in the Easter method is a lot larger:

Code:
 public string getEaster(int year)
        {
            int offset;
            int leap;
            int day;
            int temp1;
            int temp2;
            int total;

            offset = year % 19;
            leap = year % 4;
            day = year % 7;
            temp1 = (19 * offset + 24) % 30;
            temp2 = (2 * leap + 4 * day + 6 * temp1 + 5) % 7;
            total = (22 + temp1 + temp2);
            if (total > 31)
            {
                month = 4; // Easter is in April...
                day = total - 31; // ...on this day
            }
            else
            {
                month = 3; // Easter is in March...
                day = total; // ...on this day
            }
            DateTime myDT = new DateTime(year, month, day);
            return myDT.ToLongDateString();
I think I'm a bit OCD trying to understand everything, should I focus on learning how to write and use classes in my programs instead of worrying about every example I am presented with or should I be learning all the algorithms too?


Many thanks

Mike
Reply With Quote
  #2 (permalink)  
Old July 18th, 2011, 09:39 AM
Friend of Wrox
Points: 1,104, Level: 13
Points: 1,104, Level: 13 Points: 1,104, Level: 13 Points: 1,104, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 224
Thanks: 0
Thanked 30 Times in 29 Posts
Default Understanding algorithms

I originally wrote that code for one of my books on C almost two decades ago and I remember trying to understand what it did. I studied it for hours and all I got was a headache. Eventually, I "kinda" understood it and how it was tied to moon phases. At this moment, I don't have a clue how the algorithm works.

So...to answer your question. My own feeling (others may disagree) is this: If you simply want to use a time-tested algorithm, use it as described in whatever documentation is supplied with the algorithm (e.g., what arguments are passed, what's returned, and any "dangers" associated with using it). It's a tool and, just as you don't have to know how the internal combustion engine works to be able to drive a car, usually you don't have to fully understand how an algorithm works to use it. However...

If you plan on being an auto mechanic, you had best understand how an internal combustion engine works if you hope to have a successful career. Likewise, if you plan on modifying an algorithm or hope to improve it, you need to understand it completely. Simply stated, methods like the Easter method are there to be "plugged into" a program and work correctly. (Clearly, you should still test it to make sure you've copied the code correctly.) Once you are sure it's working properly, move on to the next task. However, if your task is to write a replacement or improved algorithm, you need to understand the existing algorithm completely.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
Reply With Quote
The Following User Says Thank You to DrPurdum For This Useful Post:
mjharper (July 18th, 2011)
  #3 (permalink)  
Old July 18th, 2011, 10:22 AM
Registered User
 
Join Date: Jul 2011
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I'm currently at University and hope to be a C# Developer when I graduate, I guess I was asking, as a general C# developer in a professional environment are you expected to know a ton of algorithms off hand. Reading your post I am guessing this is not the case, they are tools used to solve programming tasks :)
Reply With Quote
  #4 (permalink)  
Old July 18th, 2011, 10:33 AM
Friend of Wrox
Points: 1,104, Level: 13
Points: 1,104, Level: 13 Points: 1,104, Level: 13 Points: 1,104, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 224
Thanks: 0
Thanked 30 Times in 29 Posts
Default Understanding

If you are going through a university programming major, you will be asked to understand many algorithms, at least indirectly...that's part of the learning process. However, after graduation, your employer will expect you to deliver code on time, within budget, and without error. Those parameters pretty much force you to stand on the shoulders of others and incorporate their work in your own. You simply won't have the time to completely understand how every algorithm works...at least not while you're at work. Like all good programmers, however, you will take things home with you to digest more completely as you find the time to do so. You will never stop learning or expanding your udnerstanding of what's going on around you. When you do stop, it's time to retire...like me! Now I only spend time studying what interests me, not my (previous) employer.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
Reply With Quote
The Following User Says Thank You to DrPurdum For This Useful Post:
mjharper (July 18th, 2011)
  #5 (permalink)  
Old July 18th, 2011, 10:44 AM
Registered User
 
Join Date: Jul 2011
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

My degree is Applied Computing BSc which is pretty much a general computing degree but I enjoy programming and databases most and will likely combine the two for my project in year three (looking forward to the Database chapter in your book!)

One last question if I may,

If I was employed as a Junior Developer, what are my initial tasks likely to be? is there anything I extra I can be doing while I have the time?

Many thanks!
Reply With Quote
  #6 (permalink)  
Old July 18th, 2011, 11:27 AM
Friend of Wrox
Points: 1,104, Level: 13
Points: 1,104, Level: 13 Points: 1,104, Level: 13 Points: 1,104, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 224
Thanks: 0
Thanked 30 Times in 29 Posts
Default How to Get Ahead...

Every employer probably does things differently. In my company, a new programmer was started out with a task that likely involved code maintenance. That way, I could judge their ability to read and understand code and fix bugs, but also it served to acquaint them with the coding style we used. After that, I usually assigned them a small project, often a utility program, that they could code themselves. I personally reviewed that code to decide what they would do next. I always watched their style (to see if it matched ours), the use of comments, and documentation headers at the top of methods. I also paid close attention to how they interacted with others.

Things you can do: First, never stop learning. Read magazine articles and stay on top of new technology...it changes even faster than you think. Second, don't be afraid to learn new languages. The first is the hardest, since most languages are pretty much the same (okay, ALGOL is a different animal). Third, learn how to organize your writing...NOT code...your report writing. Too many junior people think they don't have to learn how to write. They have this idea that the boss is going to take them out to lunch and have a one-on-one relationship with him. Not gonna happen...at least for a while. You will be asked to write reports for your immediate boss and for a long time, that's how you will be judged. They expect you to write good code, but clear, concise narrative is so important to get ahead.

It's not uncommon for a boss to ask two juniors to write the same report and then judge who is the better. If you take three pages to explain something that your competition does just as well in two paragraphs, you're screwed. It's a skill and you need to work on it now. Take any "informative" article and try to condense it into bullet points. Your boss is also under the gun and if you can take less of his time to read your report than anyone else, you're on the fast track. After keeping your coding skills current, this is perhaps one of the best skills you can learn.

Finally, don't be a geek. Walking around with a propeller on your benie doesn't help you get ahead. As you advance in a company, the importance of coding skills recedes into the background and being able to speak and write clearly and concisely rises to the top. CIO's probably have a technical background, but they are socially well-groomed. Get on a daily vocabulary list and learn a new word every day and try to use them in your writing. Like they say: It's better to keep your mouth shut and let people think you're stupid than to open your mouth and remove all doubt. The opposite is also true: When you open your mouth, good sentence structure and words should flow out, not techie jargon and fuzzy logic...especially when speaking to middle (and higher) management.

I hope this helps and I wish you well in your career!
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
Reply With Quote
The Following User Says Thank You to DrPurdum For This Useful Post:
mjharper (July 18th, 2011)
  #7 (permalink)  
Old July 18th, 2011, 12:00 PM
Registered User
 
Join Date: Jul 2011
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thanks for your time Dr Purdum, I will sharpen my report writing skills!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Most hard so far to understand- The RSA Algorithm? boy18nj BOOK: Beginning Cryptography with Java 1 June 8th, 2011 11:47 PM
Don't understand which errors metinhoclam XSLT 8 July 30th, 2010 04:54 AM
Please help me understand SeanDunn BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 3 November 14th, 2009 01:38 PM
I don't understand... jmsherry ASP.NET 2.0 Basics 17 July 23rd, 2007 12:28 PM
I still do not understand aude_poullain ASP.NET 1.0 and 1.1 Basics 2 February 7th, 2007 08:11 PM



All times are GMT -4. The time now is 12:18 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.