tag:blogger.com,1999:blog-33305373076913544322024-03-19T01:48:24.623-07:00Ken's Programming BlogKenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-3330537307691354432.post-45559003573858791182021-06-18T10:44:00.003-07:002021-06-18T11:26:18.349-07:00Software Engineering Rant<h3>
Criticizing Those Who Came Before Us </h3>
Why is it so easy for us to criticize the developers that came before us? The newest generation of developers have written numerous blogs, articles and books to inform us how traditional approaches to software simply do not work, yet we continue to make the same mistakes that traditional software had. We try everything from overworking programmers to producing thick rims of documentation that no one follows or uses.<br />
<br />
Still, after years of practicing software development many businesses continue to believe that developers must deliver a constant stream of code, thinking that this is of more value to their business than taking the time to create a set plan or a real design. Holding to this practice causes businesses to steadily miss out on major profitability.<br />
<br />This is 2021 and projects are still scrapped because of poor communication that is mistaken for poor management, unforeseen technical roadblocks and incorrect requirement gathering. Pushing developers to follow these practices causes projects to be full of dead code, hacks, bugs, and either under engineered or over engineered systems and subsystems. They continue to find that strict single phase waterfall life cycles fail, yet they follow in the same footsteps, repeating the same mistakes. Many managers have only a shallow understanding of industry buzz words like agile and enterprise design, and just as many programmers are incapable of, or uncomfortable with having direct communication with management, this causes complete disfunction.<br />
<br />
It is both naïve and egotistical of us to think that our current process of software development is not fundamentally flawed. The view that we are better than our previous generation is not limited to software development and certainly is not a new concept.<br />
<div>
<br />
As we continue to adopt change and grow, it is inevitable that future generation programmers will have just as many reasons why the methods we have used are inadequate.</div>
<div>
So...What are we doing wrong?<br />
<br />
<h3>
Constantly Re-inventing Software Development</h3>
<br />
We are constantly trying to improve the way we develop software, but too many times instead of stabilizing the tools we have, someone creates a new system. These new systems bring on a different set of problems that developers are not familiar with. Where we should be able to stay focused and improve the systems we have someone comes along with an idea that focuses on one methodology, pushing for a complete change in the way software development works requiring more training and research.<br />
<div><br /></div>
<h3>
Software Engineering is a Doomed Occupation</h3>
</div>
<div>
Despite years of progression on the subject, software engineering is not a profitable career path. Instead it seems to be something that developers practice in secret for fear of perception that there is lack of productivity. Software Engineers and Project Managers are just looked at as overhead. The documentation and structure they add to the project is only looked at as nice to have at best and a nuisance at worst.</div>
<div>
<br /></div>
<div>
The title of Software Engineer is often bestowed upon a developer with no more meaning to the company or the organization than a person who has been coding for a long time. Engineers study how to make sense of large systems, they make decisions as to how the problem should be broken into smaller pieces, and have the ability to reduce maintenance and modification cost that still make up the majority of the cost of software systems today.</div>
<div>
<br /></div>
<div>
However, software engineering is not recognized or valued for its accomplishments. The perception among software vendors instead is that they don't have time to wait for an engineered solution that instead they just want a few developers to do what they are told. </div>
<div>
<br /></div>
<div>
Business managers, therefore take the responsibility, with no prior education or practical understanding of how software should work. And, actually we have begun sending business majors to to become certified Software Project Managers. They usually enter a software development team with a bunch of memorized terminology without having a firm understanding of what they are studying.</div>
<div>
<br />
<h3>
The Blue Collar Programmer</h3>
</div>
<div>
Whether you call yourself a Software Developer, Software Engineer, Lead Developer, System Architect. Most companies only see a programmer, a coder, a technical resource. And although you liken yourself closer to an architect who designs large buildings and structures, when you produce code you are no different than any other producer in a blue collar occupation.</div>
<div>
<br /></div>
<div>
The pay may be comparable or better than a structural engineer, architect or even a lawyer. When your job is to produce the product you are a low level worker and details of design are just a side note to your job. The pay may be better than say a brick layer or plumber but the company still views you the same way.</div>
<div>
<br /></div>
<div>
Nothing highlights the attitude more than the growing and now shrinking fad of outsourcing your programming to the lowest bidder. After all, programming is no different than any other blue collar, low skill labor. The client will reason to himself that there is a certain amount of work that will need to be done, there is a cheap source of labor and an expensive source of labor. Why would you choose the later when the company can scarcely tell the difference in the end result.</div>
<div>
<br /></div>
<div>
Even worse, in my humble opinion, is the absence of responsibility of the final solution. Clients are more than happy with solutions that were done quickly. Without regard for long term consequences, they glad except poor solutions that seem to do the job until they are actually used. Some are so poor in fact that the buttons and windows are there but there is no actual implementation or it was never tested.</div>
<div>
<br /></div>
<div>
Upper management rarely holds a programmer responsible for poor quality work. </div>
<h3>
The Laziness Virtue is Becoming a Hindrance</h3>
<div>
For years I have proudly proclaimed that laziness is a virtue to a programmer. By laziness I really mean that I don't want to do more work than is necessary. If I can find an api, web service or write a simpler method that reduces my code or find a way to completely eliminate the need for what I am writing than I am happy.</div>
<div>
<br /></div>
<div>
However, the development community as a whole has adopted this to the extreme. We are constantly attempting to pawn our work off onto open source SDKs, third party vendors and 4th generation tools. So much so that programmers no longer understand simple algorithms, data structures and design. Business programming can now be likened to being a general contractor, managing other works to make a bigger systems.</div>
<div>
<br /></div>
<div>
The problem with this is that we have not really made progress. Simple problems that would be obvious for us to write a custom function for 10 years ago are now available on the open market. Managers don't want the developers wasting 2 hours on writing anything they could buy or use for free.</div>
<div>
<br /></div>
<div>Third party solutions often come with an equal amount of problems. Very few of them are truly stable enough to reduce our work load. What they are really good at is appearing to work. After being put in a real world test they more often than not seem to fail. And in order to find solutions to the problem with the third party tool, developers are forced to study at detail the inter working of it. It cost 2 hours of our time to download and reference a third party solution to our problem and costs the company more time to make it "really work" then it would have cost had the developer remembered how to implement a trivial algorithm.</div>
<div>
<br /></div>
<div>
As a solution this conundrum, businesses adopt large swiss army knife frameworks. These frameworks are often too large for the vendor to reasonably test and end up having more flaws than the tons of smaller solutions available. </div>
<h3>
The Failure of 4th and 5th Generation Languages</h3>
<div>
Like the search for the holy grail, developers are in constant search for a next generation programming language that can increase productivity. However, our attempts at implementing them have been hindered by the instability of existing tools, and by a fundamental flaw in the logic that says we need a 4th or 5th generation toolset.</div>
<div>
<br /></div>
<div>
The idea that 3rd generation tools such as Eclipse and Visual Studio and programming languages like C++, C# and Java have made us more productive than languages such as pascal, ADA and ansi C is misguided at best. What these toolsets do is attempt to guide us into making a well designed solution.</div>
<div>
<br /></div>
<div>
However, software design in itself is not promoted in the industry. As much as the tools can help you design software, they can not design it for you. In order to design a system you must understand fundamental design methods. Methods that have remained the same since pre-1970's and have since only changed in terminology and not in meaning.</div>
<div>
<br /></div>
<h3>
Replacing Software Design are Canned Patterns and Solutions</h3>
<div>
After decades of attempting to push fundamental software design, we have given up on designing systems and instead have taken to finding a canned set of patterns that solves problems for us. We have then pushed this on to the "great unwashed" developers of the past who simply followed traditional design methods based on logic and engineering principles.<br />
<br />
Admittedly, these patterns in our solutions offers an improvement over non-designed systems. However, they are most often used to replace any kind of forethought in a project. Lets do a 3-tier system and let the system play out how it plays out. Make sure to put in factories and dependency injection, that usually makes better systems.<br />
<br />
The next step inevitable, is that our toolsets push a set of patterns into your solution. In an attempt to improve code for you, frameworks such as Ruby on Rails and Microsoft MVC have made it fairly difficult to not use these patterns when using their tools. Just as C++ and C# attempt to improve code by forcing the Object Oriented Paradigm on its developers these toolset often have no effect on developers that do not understand design principles in the first place.<br />
<br />
<h3>
Non-Technical Problems are Solved with Technical Solutions</h3>
Solutions to the problems the industry faces are not hard to find. At the moment there is no lack of frameworks, toolsets, higher level programming languages, patterns or methodologies. In fact they may do too much for us.<br />
<br />
When it comes to 3rd party tools, what is needed is a correct implementation to begin with. 3rd party vendors, are capable of producing high quality well tested, well documented frameworks. But so far they have not found it profitable. We as developers seldom hold them to a high standard. We have been more than willing to put up with any bugs and flaws in their systems.<br />
<br />
Instead of 4th and 5th generation languages that write code for us. Would it not be more productive to give us meaningful error messages? And, instead of generating sql statements and the programming code to go with it. Could we make the database api and sdks work the way they should? Is it not more profitable to the developer to remove poorly designed classes and non-working methods in the current api then to create canned scripts to deal with generating the obscure code.<br />
<br />
Furthermore, would it not be more profitable to simply teach fundamental design principles than to blame our poorly written systems on a lack of a new concept, pattern, tool, and or software methodology. Like sheep, the industry blindly falls for the latest snake oil. RAD, Agile, Extreme Programming, SCRUM, DevOps and any other buzz word meant to fix the current ailments all seem to address a problem that already has a viable solution.<br />
<br />
However, the real solution to the problem is somewhat hard to swallow and is actually non-technical in its nature. The problem lies between the keyboard and the computer chair. Developers and software managers for that matter, that are properly trained and have a discipline about their work will produce high quality, easily maintained systems.<br />
<br />
<br />
<br />
<br /></div>
<div>
<br /></div>
Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com0tag:blogger.com,1999:blog-3330537307691354432.post-57331997142494998602019-06-04T18:12:00.000-07:002019-06-06T10:28:59.799-07:005 Quick Ways to be a Better Programmer<h3>
1. Take Advantage of the Debugger</h3>
<div>
If you are still using message boxes and Console.WriteLine statements to determine what is going on inside your program than stop now. You don't have to be an expert at the debugger to take advantage of the debugger.</div>
<div>
<br /></div>
<h3>
2. Ask Someone for Help When You are Stuck</h3>
<div>
If you are the lone programmer type you may find it difficult to ask others for help. There is nothing more valuable than having other developers give insight into your problem. If you are using 3rd party libraries than you should take advantage of user support.</div>
<div>
<br /></div>
<h3>
3. Don't be a Yes Man</h3>
<div>
Don't blindly follow management when it comes to creating software. This is the sign of a more senior developer and will help your company a great deal. Always be tactful and respectful to your non-technical boss but remember that they could not begin to understand the problems you are facing. Its up to you to give them guidance when it comes to making technical decisions. </div>
<div>
<br /></div>
<h3>
4. Use a Code Standard</h3>
<div>
A coding standard is one of the easiest ways you can improve your code without knowing any engineering or studying any complex theories on development methodologies. You don't need to re-invent the wheal here. Microsoft along with other large software companies publish their coding standards online. </div>
<div>
<br /></div>
<div>
<br /></div>
<h3>
5. Take the Initiative</h3>
<div>
If you see bugs in the software or see areas in the code that need fixing than you should correct them. The "If it ain't broke don't fix it." mentality does not suite most projects. Don't wait for your project manager, QA or customers to report the bugs. Remember you are the first like in development. Buts that you catch and correct save the company lots of time, effort and money.</div>
<a target="_blank" href="https://www.amazon.com/dp/B07DLPWYB7?ref_=assoc_tag_ph_1524210885446&_encoding=UTF8&camp=1789&creative=9325&linkCode=pf4&tag=startiprogra-20&linkId=a0db2217fdac6008d71c39fc3ddfdf83">Shop Amazon Devices - Introducing the all-new Kindle</a><img src="//ir-na.amazon-adsystem.com/e/ir?t=startiprogra-20&l=pf4&o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1tag:blogger.com,1999:blog-3330537307691354432.post-15149422002083681182019-06-04T17:39:00.000-07:002019-06-06T10:42:05.139-07:00How do you program when you can't?<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVtPP5sWS80AB_sgtO69pK4pBfNBLiV8giqKiofJ0mJCF5Sq3qbR1oBxYf0gj3Nww56zuXO8gORQh1DF_-SMOPBDZ4zWh_2W7Ehxn9unH3m-GOeYx6rHQP1mrboiA61IfMBdw3B8L7OQI/s1600/computer-2788918_640.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="423" data-original-width="640" height="211" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVtPP5sWS80AB_sgtO69pK4pBfNBLiV8giqKiofJ0mJCF5Sq3qbR1oBxYf0gj3Nww56zuXO8gORQh1DF_-SMOPBDZ4zWh_2W7Ehxn9unH3m-GOeYx6rHQP1mrboiA61IfMBdw3B8L7OQI/s320/computer-2788918_640.jpg" width="320" /></a></div>
<br />
<br />
I woke up this morning with no desire to program a computer. Have you been there before? It's scary when you lose your job and find yourself unable to work on even the smallest task. I began to think that I would never write a program again. When you begin to feel that way it makes you feel worthless. That is how I felt because programming has been my only means to support my family.<br />
<br />
After dedicating nearly three years of my life to a company that I love I was unexpectedly laid-off due to unforeseen medical circumstances. The lay off was coming, this was known for weeks, though I was not expecting that I would be let go.<br />
<br />
My reaction has been to focus on my wife and our kids. If only I can build them up and make them stronger then I can, through their strength, bring our family back on top.<br />
So all day I worked to balance my wife's needs with our kids' needs. We have had a good day, talking at length about writing a book, making plans that will help bring our family back together. Our highest priorities are to heal our kids' hearts and also heal their biological Mom's heart.<br />
<br />
I am blessed to have my wife at my side because together we can do anything. We can not afford to lose focus. I can't keep feeling as though I am pushing with all my heart, only to find myself friendless and jobless without a dime to my name.<br />
It's time to pull-up, defend our families' honor and rise above the world to achieve God's plan.<br />
<br />
<div class="alignleft">
<a href='https://www.blogger.com/blogger.g?blogID=3330537307691354432#editor/target=post;postID=3304747109157495987;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=8;src=postname'>I Knew a Programmer that Went Completely Insane</a>
<script type="text/javascript">
amzn_assoc_ad_type = "banner";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_placement = "assoc_banner_placement_default";
amzn_assoc_campaigns = "amzn_erd_jg_evg";
amzn_assoc_banner_type = "promotions";
amzn_assoc_p = "12";
amzn_assoc_banner_id = "00DVP99CM1Z1AZ9XJA02";
amzn_assoc_width = "300";
amzn_assoc_height = "250";
amzn_assoc_tracking_id = "startiprogra-20";
amzn_assoc_linkid = "da373d3a4e6986d976d88250db7efcef";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1"></script>
</div>
Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com2tag:blogger.com,1999:blog-3330537307691354432.post-70201800819124100912014-04-22T14:40:00.003-07:002016-03-31T13:42:22.094-07:00Why Don't You Use Factories?After reading and applying traditional software design techniques taught by some of the best professional developers such as <a href="http://yourdon.com/publications/">Edward Yourdon</a>, <a href="https://www.cs.unc.edu/~brooks/">Frederick Brooks</a>, <a href="http://martinfowler.com/">Martin Fowler</a>; I thought that I was fairly talented at designing and writing software systems. However, if there is a single technique that I overlooked when designing/implementing software solutions it is the factory. Factories, have been around for quite a while but they have recently, within the last 5 years or so, become an important tool for me.<br />
<div style="background-color: #ffff99; border-radius: 10px; color: grey; margin: 6px; padding: 10px;">
<i>If you just started reading this and you know about dependency injection...this is not an argument that factories are better than dependency injection frameworks at all. The only argument that I can come up with that they are better than DI frameworks is that factories are a lot lighter weight and you may save some time not jumping through technical hoops that a DI framework will require.</i>
</div>
<h1>
<span style="font-size: large;">
What is a Constructor?</span></h1>
You may have been expecting at this point that I would start off by detailing what exactly a factory is, but in fact, I can't really explain factories unless I explain what a constructor is. I assume if you are reading this then you must, at some level, understand object oriented programming. If you do not, may I suggest a good book on the subject matter as listed below:
<br />
<table>
<tbody>
<tr><td><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=startiprogra-20&marketplace=amazon&region=US&placement=1133188222&asins=1133188222&linkId=HF7F5MSVZ6ABD2TF&show_border=true&link_opens_in_new_window=true" style="height: 240px; width: 120px;">
</iframe>
</td>
<td><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=startiprogra-20&marketplace=amazon&region=US&placement=0321861272&asins=0321861272&linkId=BPRGZZBYFL2VXJVA&show_border=true&link_opens_in_new_window=true" style="height: 240px; width: 120px;">
</iframe>
</td>
<td><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=startiprogra-20&marketplace=amazon&region=US&placement=B00C7C32I6&asins=B00C7C32I6&linkId=NXEYMM76NT4ZDP37&show_border=true&link_opens_in_new_window=true" style="height: 240px; width: 120px;">
</iframe></td>
</tr>
</tbody></table>
However, as much as you may understand how to write software in an object oriented manner, you may not actually use constructors that much and might not truly understand the concept of constructors.
<br />
Constructors are where we place logic that happens when an object is allocated into memory and where any member variables are initialized. <br />
Dependencies are anything the object needs to complete its intended purpose. A dependency can be a simple variable such as an integer, float, or string that can represent things like file names, account codes, and index keys; or... it can be another object that the object depends on to complete its purpose such as an SDK/API wrapper or a data access layer object. In general, anytime you use the new keyword it should be in the constructors.
<br />
<br />
However most of the code I have worked on, and for the most part a great majority of the code that I have created over the years, very rarely use constructors for anything. So, if constructors are how we should be handling dependencies why do we hardly ever use them?
<br />
<br />
<h3>
You Just Don't Get Dependencies</h3>
If you are not doing the majority of your object initiation inside of a constructor then you probably just don't get dependencies. Your code is most likely littered with innocent looking new statements everywhere and I know exactly where they are, they are used exactly before you need them. In fact, most developers don't even have the common courtesy to put them at the beginning of their overly bloated methods.
<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<h4>
<span class="kwrd">An example application that does not use dependencies:</span></h4>
<pre class="csharpcode"><span class="kwrd">namespace</span> MyApplication
{
<span class="kwrd">public</span> <span class="kwrd">class</span> MyClass
{
<span class="kwrd">public</span> MyClass()
{
<span class="rem">//I hardly ever put anything here...</span>
}
<span class="kwrd">public</span> <span class="kwrd">void</span> DoSomethingCool()
{
<span class="kwrd">var</span> appSettings = <span class="kwrd">new</span> Object();
<span class="rem">//Code.....</span>
<span class="rem">//Explain how to use emailSDK...</span>
<span class="rem">//........</span>
<span class="kwrd">var</span> emailSDK = <span class="kwrd">new</span> Object();
emailSDK.ServerAddress = <span class="str">"..."</span>;
emailSDK.UseEncryption = <span class="kwrd">true</span>;
emailSDK.Init();
<span class="rem">//Code.....</span>
<span class="kwrd">string</span> fileName = <span class="str">"C:\\temp\inputFileName"</span>;
<span class="rem">//Code....</span>
<span class="kwrd">var</span> myObject = <span class="kwrd">new</span> Object();
<span class="rem">//Code...</span>
emailSDK.Send(...);
}
}
}</pre>
<br />
The ideal solution is that your dependencies are properties/members of the base class and that your dependencies are initialized inside of your constructor. Sometimes (but very rarely), it makes more sense to initiate objects directly inside a method. However, most of the time it just leads to bad code.
<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<h4>
Moving your dependencies to your constructor:</h4>
<pre class="csharpcode"><span class="kwrd">namespace</span> MyApplication
{
<span class="kwrd">public</span> <span class="kwrd">class</span> MyClass
{
<span class="kwrd">public</span> MyClass(<span class="kwrd">string</span> fileName)
{
<span class="rem">//This is where I set up my object for use</span>
AppSettings = <span class="kwrd">new</span> Object();
<span class="rem">//Here is how we setup the email sdk....</span>
<span class="kwrd">var</span> EmailSdk = <span class="kwrd">new</span> Object();
EmailSdk.ServerAddress = <span class="str">"..."</span>;
EmailSdk.UseEncryption = <span class="kwrd">true</span>;
EmailSdk.Init();
FileName = <span class="str">"C:\\temp\\inputFileName.txt"</span>;
}
<span class="rem">//Its really clear what this class needs in order to do its job....</span>
<span class="kwrd">private</span> <span class="kwrd">string</span> FileName { <span class="kwrd">get</span>; <span class="kwrd">set</span>; }
<span class="kwrd">private</span> Object MyObject { <span class="kwrd">get</span>; <span class="kwrd">set</span>; }
<span class="kwrd">private</span> Object EmailSdk { <span class="kwrd">get</span>; <span class="kwrd">set</span>; }
<span class="kwrd">private</span> Object AppSettings { <span class="kwrd">get</span>; <span class="kwrd">set</span>; }
<span class="rem">//---------------------------------------------------------------------</span>
<span class="kwrd">public</span> <span class="kwrd">void</span> DoSomethingCool()
{
EmailSdk.Send();
WriteToFile(FileName);
<span class="rem">//You get the point</span>
}
<span class="kwrd">public</span> <span class="kwrd">void</span> DoSomethingElseCool()
{
EmailSdk.Send(AppSettings.RegionManager);
WriteToFile(FileName);
}
}
}
</pre>
<br />
All of the dependency initiation logic that is placed directly at the method level instead of the constructor level are a major cause of method bloat. The second example above really demonstrates how small our methods become when the constructor is used to create objects rather than directly creating them as needed.
<br />
The side effect, when you really start to think using dependencies, is that you start solving your problems at the class level rather than the method level. If you do as I suggest in this article, then methods will be small and flexible and you will have more classes in your code then usual. That is, in my experience, a good thing because now you are thinking and writing code at a higher level.
<br />
<div style="margin: 5px; padding: 5px;">
<i>There is much more information regarding dependencies then I care to cover in this article.</i>
</div>
<br />
<h3>
Factories Are Way Cooler Than Constructors</h3>
As cool as constructors are, factories are way way cooler. Interesting enough, once I started using factories to make better code it really taught me how to use constructors in a more constructive way.
<br />
Factories are basically constructors that are detached from the class they create. <span style="background-color: white;">By using factories, a great deal of logic that is usually in the same class can be separated into different classes.</span> Many times objects in your solution will contain similar dependencies. It is much easier to manage these dependencies by putting them into a common class. For instance, all Data Access Components could be using the same connection string.
<br />
This concept comes from industrial factories where products are put together at a common building (factory) so that the details of how they are constructed are not needed in order to begin to use the product. For instance, with a laptop you don't have to make the decision of what keyboard to purchase because it was placed/injected into your laptop at the factory and is not an external component like in desktop computers. This makes a laptop a much easier real life object to make use of then a desktop computer. I don't even need to plug it in...I flip up the screen and press the power button and I have a working computer.
<br />
In the same way, when I am writing a class suddenly things like file locations, dialog box methods, and application wide settings are just conveniently constructed and ready for me to use.
<br />
<br />
<h3>
Factory Methods</h3>
Factory members are functions/methods that act as a constructor for an object. They are functions that return a fully functional ready to be used object. You do not necessarily need to put them inside of a special factory class. They can exist in a parent object that is not purely a factory class or it can be put inside of the object that it creates or in any object.
<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"> <span class="kwrd">public</span> <span class="kwrd">static</span> AccountDataManager CreateAccountDataManager()
{
<span class="kwrd">var</span> adm = <span class="kwrd">new</span> AccountDataManager();
adm.DataFileName = <span class="str">"Accounts.txt"</span>;
<span class="kwrd">return</span> adm;
}
</pre>
<br />
<h3>
Static Factory</h3>
Static factories may be the most common implementation of the factory pattern. The advantage of writing a static class with static factory methods, as shown below, is that it is a fairly easy approach and you don't have to think much about how to access the factories. You can simply call them like any other static function anywhere in you code without regard for initiating a new factory object.
<br />
For small projects this is a good approach because its easy for yourself and for other developers to understand. I also recommend that you become familiar with this approach because it is very common in existing frameworks and code in general. You will find it in both new and older code bases.
<br />
<b><span style="font-size: x-small;"><br /></span></b>
<br />
<h4>
<b>Declaring a single factory for the application:</b></h4>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"><span class="kwrd">namespace</span> FactoryExample
{
<span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">class</span> AppFactory
{
<span class="kwrd">public</span> <span class="kwrd">static</span> AccountDataManager CreateAccountDataManager()
{
<span class="kwrd">var</span> adm = <span class="kwrd">new</span> AccountDataManager();
adm.DataFileName = <span class="str">"Accounts.txt"</span>;
<span class="kwrd">return</span> adm;
}
<span class="kwrd">public</span> <span class="kwrd">static</span> ContactDataManager ContactDataManager()
{
<span class="kwrd">var</span> cdm = <span class="kwrd">new</span> ContactDataManager();
cdm.DataFileName = <span class="str">"Contacts.txt"</span>;
<span class="kwrd">return</span> cdm;
}
}
}</pre>
<pre class="csharpcode"><b>
</b></pre>
<h4>
<b>Using the factory in your main program:</b></h4>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"><span class="kwrd">namespace</span> FactoryExample
{
<span class="kwrd">class</span> Program
{
<span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
<span class="kwrd">var</span> accountManager = AppFactory.CreateAccountDataManager();
<span class="kwrd">var</span> account = <span class="kwrd">new</span> Account() { accountNumber = 23, Balance = 23.23M };
accountManager.Create(account);
<span class="kwrd">var</span> contactManager = AppFactory.CreateContactDataManager();
<span class="kwrd">var</span> contact = <span class="kwrd">new</span> Contact() { CustomerId = 12, Name = <span class="str">"John Smith"</span>, Email = <span class="str">"jsmith200@yahoo.com"</span> };
contactManager.Create(contact);
}
}
}
</pre>
Most of the time I actually create the main application as a separate class and create it in side of the "program" class using a factory method to create my application as I show below:<br />
<h4>
<b>Declaring the factory method:</b></h4>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"> <span class="kwrd">public</span> <span class="kwrd">static</span> FactoryExampleApp CreateApplication()
{
<span class="kwrd">var</span> app = <span class="kwrd">new</span> FactoryExampleApp();
app.AccountDataManager = CreateAccountDataManager();
app.ContactDataManager = CreateContactDataManager();
<span class="kwrd">return</span> app;
}</pre>
<pre class="csharpcode"></pre>
<h4>
<b>Usage of the factory:</b></h4>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"><span class="kwrd">namespace</span> FactoryExample
{
<span class="kwrd">class</span> Program
{
<span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
<span class="kwrd">var</span> app = AppFactory.CreateApplication();
app.Run();
}
}
}</pre>
<h3>
Single Factories or Multiple Factories</h3>
The above examples, mostly because its easier for me to write an example for, use a single factory for your entire program. I call that factory <b><i>AppFactory</i></b> in the above code.
<br />
<br />
<h3>
Non-Static Factory</h3>
It might just be personal preference but I don't like static methods in my code. If I can help it, I will write the factories in non-static class and have them as common properties. The simplest approach, as shown below, will just require an extra new statement when you want to use the factory.
<br />
<br />
<b>Declaring the non static factory:</b><br />
<pre class="csharpcode"> <span class="kwrd">public</span> <span class="kwrd">class</span> NonStaticAppFactory
{
<span class="kwrd">public</span> FactoryExampleApp CreateApplication()
{
<span class="kwrd">var</span> app = <span class="kwrd">new</span> FactoryExampleApp();
app.AccountDataManager = CreateAccountDataManager();
app.ContactDataManager = CreateContactDataManager();
<span class="kwrd">return</span> app;
}
<span class="kwrd">public</span> AccountDataManager CreateAccountDataManager()
{
<span class="kwrd">var</span> adm = <span class="kwrd">new</span> AccountDataManager();
adm.DataFileName = <span class="str">"Accounts.txt"</span>;
<span class="kwrd">return</span> adm;
}
<span class="kwrd">public</span> ContactDataManager CreateContactDataManager()
{
<span class="kwrd">var</span> cdm = <span class="kwrd">new</span> ContactDataManager();
cdm.DataFileName = <span class="str">"Contacts.txt"</span>;
<span class="kwrd">return</span> cdm;
}
}</pre>
<b><br /></b>
<b>Simple usage of the factory:</b><br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"><span class="kwrd">namespace</span> FactoryExample
{
<span class="kwrd">class</span> Program
{
<span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
<span class="kwrd">var</span> app = (<span class="kwrd">new</span> NonStaticAppFactory()).CreateApplication();
}
}
}
</pre>
<div style="background-color: #ffff99; border-radius: 10px; color: grey; margin: 6px; padding: 10px;">
The only thing I will say about static methods are that they are in fact pure evil. So unless you know why they are evil, then you shouldn't use them at all. In fact, what where they thinking when they allowed them in OO languages?
</div>
<br />
With non-static classes you can also put the factory into a property on the base class and inherit from it when ever you want to access its factory methods.<br />
<b>Factories using a base class:</b><br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"> <span class="kwrd">public</span> <span class="kwrd">class</span> MyBase
{
<span class="kwrd">public</span> NonStaticAppFactory Factory
{
<span class="kwrd">get</span>
{
<span class="kwrd">return</span> <span class="kwrd">new</span> NonStaticAppFactory();
}
}
}
<span class="kwrd">public</span> <span class="kwrd">class</span> MyCoolClass: MyBase
{
<span class="kwrd">public</span> <span class="kwrd">void</span> DoSomeCoolStuff()
{
<span class="kwrd">var</span> dataManager = Factory.CreateAccountDataManager();
<span class="kwrd">var</span> account = dataManager.Read(123);
<span class="kwrd">var</span> balance = account.Balance;
Console.WriteLine(balance);
}
}</pre>
<br />
It should be obvious that there are several other ways to declare and use factories. Some would prefer having a single <i><b>Create </b></i>method and just pass either a string or Type instance into the method to distinguish what type of object should be created.<br />
<h3>
</h3>
<h3>
Factories are also good for...</h3>
<ul>
<li>Factories are also good for managing the technique used for creating objects. For instance we might want to return a single object every time the factory method is called (<i>Singleton pattern</i>).</li>
<li>They can be used to return an interface or purely abstract class instead of a hard object. This is really important because many designers prefer to use abstract classes to hide details instead of private member variables. </li>
</ul>
<br />
<div>
<iframe border="0" frameborder="0" height="90" marginwidth="0" scrolling="no" src="http://rcm-na.amazon-adsystem.com/e/cm?t=startiprogra-20&o=1&p=48&l=ur1&category=musicandentertainmentrot&f=ifr" style="border: none;" width="728"></iframe>
</div>
<div style="background-color: #ffff99; border-radius: 10px; color: grey; margin: 6px; padding: 10px;">
<h1>
When should you not use Factories?</h1>
<ul>
<li>Your object is going to be used with an existing SDK/API that expects a constructor and does not understand factory methods.</li>
<li>Heavy usage of factories would violate the conceptual integrity of the software solution. Simply put adding factories to an existing, well written application, that does not use factories could make your code less maintainable because it is not like the rest of the system. </li>
<li>Usage of factories is not generally accepted by the programming team and using the technique will simply add confusion when others look at your code. A manager or peer some place or somewhere might begin to say “you don't play well with others.”</li>
<li>Some software systems, for one reason or another, do not lend themselves well to factories. For instance some SDKs, such as the Microsoft .NET DOM library, require child objects to be created by their parent objects. XmlElements must be created using an XmlDocument object. Trying to force the framework into your own factory pattern can prove to be difficult and you may be better off just using the DOM as it was intended instead of adding your own flavor of factories on top of it. </li>
<li>You have a more elegant dependency injection framework or approach. </li>
<li>Your program is very small and factories would not really help because there are not that many dependencies to begin with. In this case, I would argue that usage of constructors vs factories is pretty much a wash. If you know how to use factories then it is no more difficult to write factories then it is to write constructors.</li>
<li>If your solution uses inheritance heavily then factories would be hard to implement everywhere. Instead it could be used for returning higher level objects or for certain parts of your solution.</li>
</ul>
</div>
Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com0tag:blogger.com,1999:blog-3330537307691354432.post-81546831652241391932014-01-22T15:24:00.001-08:002016-03-31T13:42:11.325-07:00Working with Views in Sage 300 ERP ( Accpac )In Sage 300 ERP views are used as a standard way of manipulating and retrieving data. You will also need to use views in order to execute some commands. Views in Sage 300 closely resemble MVC and MVVM patterns that have been used when simplifying user interfaces. Becoming familiar with these patterns may help you to understand how things work in Sage 300.<br />
Views match up closely to what you see on the Sage 300 user interface. However, you may find that the names for certain fields are not the same as you see on your screen. Most fields in Sage 300 are abbreviated and some are named completely different from the label on the forms.<br />
<h1>
Why not use the database?</h1>
If you are handy with SQL and know how to find the Sage 300 databases then you might be tempted to circumvent the SDK all together and go straight for accessing Sage via the database. Although this may be necessary in some situations, I recommend that you save this as a last resort for several reason.<br />
<h3>
The business logic will be bypassed</h3>
There is actually a lot going on behind the scenes when you are using the application. If you go straight to the database then the business logic can be bypassed. This can mean that you will have to recalculate calculated fields, updated other tables based on your changed values, and/or write your own data validation routines.<br />
I would like to point out that this can be a problem with any application that you work with. It is typically poor practice to go straight to the database when an SDK is available. Again, if its the only way we can accomplish the task then it is acceptable.<br />
<h3>
You might corrupt the database</h3>
Sage 300 does things a little differently then standard SQL, so you may inadvertently insert a value that it does not expect. For instance a numeric field can be stored as a string and if an extra space or a leading zero is not populated correctly then you can cause unexpected results.<br />
<h3>
Distribution can be a little more tricky</h3>
If you are writing triggers, stored procedures etc. then you could make distributing your application a little difficult. For small one off solutions this might be a valid tradeoff. However, if you are distributing to several users then it can become a problem. What if you have credential problems? What if they revert to an old version of the database?<br />
<h1>
Using Views</h1>
Please refer to the <a href="http://startingdotneprogramming.blogspot.com/2013/12/getting-started-with-accpac-programming.html">previous example</a> where we connected to Sage 300 and retrieved the current version information if you need help getting started. Instead of retrieving a version, this time we will retrieve all the data in the view. The code is as follows:<br />
<br />
<pre class="csharpcode"><span class="kwrd">using</span> System.Linq;
<span class="kwrd">using</span> System.Text;
<span class="kwrd">using</span> System.Threading.Tasks;
<span class="kwrd">namespace</span> Example2
{
<span class="kwrd">class</span> Program
{
<span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
<span class="rem">//Connect to the sample company</span>
<span class="kwrd">var</span> accpacSession = <span class="kwrd">new</span> AccpacSession();
accpacSession.Init(<span class="str">""</span>, <span class="str">"XY"</span>, <span class="str">"XY1000"</span>, <span class="str">"61A"</span>);
accpacSession.Open(<span class="str">"ADMIN"</span>, <span class="str">"ADMIN"</span>, <span class="str">"SAMINC"</span>, DateTime.Now, 0, String.Empty);
<span class="rem">//Open the db link. This should be the Company link type and not the system. </span>
<span class="kwrd">var</span> dbLink = accpacSession.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READONLY);
AccpacView view;
<span class="kwrd">int</span> result = dbLink.OpenView(<span class="str">"AR0024"</span>, <span class="kwrd">out</span> view);
<span class="rem">//This just says find all records. We pass it an empty string for the search expression</span>
view.Browse(String.Empty, <span class="kwrd">true</span>);
while (view.Fetch())
{
<span class="kwrd">string</span> id = view.Fields.FieldByName[<span class="str">"IDCUST"</span>].get_Value().ToString();
<span class="kwrd">string</span> name = view.Fields.FieldByName[<span class="str">"NAMECUST"</span>].get_Value().ToString();
<span class="kwrd">string</span> phone = view.Fields.FieldByName[<span class="str">"TEXTPHON1"</span>].get_Value().ToString();
Console.WriteLine(<span class="str">"{0}\t{1}\t{2}\t"</span>, id, name, phone);
}
<span class="rem">//Strange things will happen if you do not close both the view and the db link.</span>
view.Close();
dbLink.Close();
<span class="rem">//Always close the session when you are done.</span>
accpacSession.Close();
}
}
}
</pre>
The above example shows a very simple use case were we just want to retrieve a few fields and display them. Although you can supply filter information and let the SDK filter your data, I find it useful to grab the entire view and manipulate it using LINQ or custom code. I still use the SDK to filter data if the dataset is to large. I can, for instance, only grab records that have been modified today.<br />
You may also find it useful to refer to the <a href="http://www.kcsvar.com/sage-300-aom/">Sage 300 Data Dictionary</a> for a reference to what fields are in what view.Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1tag:blogger.com,1999:blog-3330537307691354432.post-82062622681497440682013-12-19T06:29:00.003-08:002014-01-21T14:04:40.315-08:00Getting Started with Accpac Programming<div class="MsoNormal">
Recently I have accepted a new position at <b><a href="http://www.kerr-consulting.com/">Kerr Consulting</a></b> that
specializes in integrating ERP and other financial software packages such as <i>Quick Books</i>
with existing software. Most of our work is related to Sage products and I have
been specifically tasked with becoming an expert at <a href="http://kerr-consulting.com/solutions/accounting-for-profit/sage-accpac/?zPage=8a7c9fef2ce30fdd012d51e543d52d90">Sage 300 ERP (Accpac)</a> programming.</div>
<div class="MsoNormal">
<o:p></o:p><br /></div>
<div class="MsoNormal">
<br /></div>
<h3>
A Simple Example</h3>
I find it difficult to find
simple examples when getting started programming any new platform. So I will
start out with a very basic example of how to simply connect to Accpac.<br />
<br />
<h3>
Dependencies</h3>
<h1>
<o:p></o:p></h1>
<div class="MsoNormal">
</div>
<ul>
<li>We are programming with the .NET Framework version 4.5 and MS
Visual Studio 2012. There is no problem with downgrading to lower versions of
.NET and Visual Studio.</li>
<li>We are using Sage 300 ERP 2012/ 6.1 for the example code. This must
be installed on your system in order to write software for sage.</li>
<li>Additionally you will need to install the Sage 300 ERP SDK
v2012 that should be provided for you. The installation is named SDK61A.exe in
my system.</li>
</ul>
<h3>
References</h3>
<h1>
<o:p></o:p></h1>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
You must make a reference to the AccPac COM library in order
to access the SDK in .NET. Under your project right click on <i>References</i> and click <i>Add Reference…</i> Then click on the <i>COM</i> tree node on the left hand side of
the form. Check the item named ACCPAC COM API Object 1.0 and then click ok to
finish adding the reference. You can see where I have added the reference to my
project below:<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiTv7N1KTBSZ7COsDe2JgPcol8wonEv-NZumt2iU1XoJCNceDgf7ukC_W5hi1NmrKw97zqe9S269bsp2B2LX7zqJQy3IziiVzUo9-cy8Eyh-YRl6T-rsyR9TtUQ8h9dHaOTIvZ5h6DzR0/s1600/AddReference.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiTv7N1KTBSZ7COsDe2JgPcol8wonEv-NZumt2iU1XoJCNceDgf7ukC_W5hi1NmrKw97zqe9S269bsp2B2LX7zqJQy3IziiVzUo9-cy8Eyh-YRl6T-rsyR9TtUQ8h9dHaOTIvZ5h6DzR0/s640/AddReference.png" height="316" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h3>
The Code</h3>
<div class="MsoNormal">
<span style="font-family: inherit;">After your reference is added to your project the below code
can be used to connect to Accpac and retrieve the Application Version you are
programming on. </span><o:p></o:p></div>
<div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode"><span class="kwrd">namespace</span> Example1
{
<span class="kwrd">class</span> Program
{
<span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
<span class="kwrd">var</span> accpacSession = <span class="kwrd">new</span> AccpacSession();
<span class="rem">//Initialize the session. You will need to pass another version instead of 61A.</span>
<span class="rem">//for AppVersion. I am using 6.1A so I pass 61A here.</span>
accpacSession.Init(<span class="str">""</span>, <span class="str">"XY"</span>, <span class="str">"XY1000"</span>, <span class="str">"61A"</span>);
<span class="rem">//This is the default setup for SAMINC but it might be different on your system</span>
accpacSession.Open(<span class="str">"ADMIN"</span>, <span class="str">"ADMIN"</span>, <span class="str">"SAMINC"</span>, DateTime.Now, 0, String.Empty);
<span class="rem">//Write out the Application Version. It should be 61A just as you passed to Init.</span>
Console.WriteLine(accpacSession.AppVersion);
<span class="rem">//Always close the session when you are done.</span>
accpacSession.Close();
}
}
}
</pre>
</div>
<h3>
Where to Get More Help</h3>
<h1>
<o:p></o:p></h1>
<div class="MsoNormal">
<br />
<ul>
<li><span style="font-family: inherit;">The best resource for SDK help is <a href="http://smist08.wordpress.com/">Stephen Smith’s blog</a>.
There is a ton of information there that you won’t find anywhere else including
the Sage documentation.</span></li>
<li><span style="font-family: inherit;">There is also a <a href="http://dppwiki.sage300erp.com/wiki/Main_Page">wiki page for Sage 300 ERP</a> that has a
variety of examples. However, you will have to be a member of the developer
network to view or updated it.</span></li>
</ul>
<o:p></o:p><br /></div>
<div class="MsoNormal">
<o:p></o:p><br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<br /></div>
<div>
<div class="MsoNormal">
<o:p></o:p><br /></div>
</div>
Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com6tag:blogger.com,1999:blog-3330537307691354432.post-33047471091574959872013-04-18T20:23:00.001-07:002014-04-24T14:57:20.451-07:00I Knew a Programmer that Went Completely Insane<span style="font-size: 13.5pt;">Not long ago one of our programmers just
lost it and he lost it good. He walked into the manager’s office and began
screaming strange things. If I didn't know him as well as I did I would have thought that he was on
some kind of drug. But what had really happened was nothing short of a complete
mental breakdown.</span><br />
<div style="margin: 0in 0in 0.0001pt;">
<br /></div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: 13.5pt;">He was one of the
hardest workers I had seen in the industry. He would frequently stay
after hours to work on projects; He was always available when management needed
someone to rush a job out over the weekend. During this time the Company was not making money
and they needed the work done as quickly as possible, so any software that had to
be rushed to a customer was automatically assigned to him. His willingness to push himself to get a job done is what they liked about him.</span></div>
<div style="margin: 0in 0in 0.0001pt;">
<br /></div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: 13.5pt;">However, his
productivity was not so great when he landed in a mental institution. I was
the one that the company sent to visit him in the hospital to check
on him after his breakdown. He asked me for a pen and a piece
of paper so he could write a program down. "I think I still got
it" he said, as he sat there in his hospital robe. He wrote two
lines of code on the piece of paper and then began to weep uncontrollably. </span><span style="font-size: 13.5pt;">The company let
him go after about three months in a hospital and a
few threatening phone calls. He ranted about how he should be the CEO
and that he was going to be the new face of the company.</span></div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: 13.5pt;"><br /></span>
<span style="font-size: 13.5pt;"> Later he spoke about
how the effort he put into the company should have given him more respect and a better position. Despite being well treated and paid, for his hard work, he was
still looked at as just a worker that produced well. He was never considered to be a key player in
the company.<o:p></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt;">
<br /></div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: 13.5pt;">It may be hard to
swallow but the extra effort and hours that you put into your job as a software
developer does not usually amount to someone higher up thinking you should run
the company. It has been my experience that good producers are more likely to
be asked to continue to produce. If they moved you to a higher position and
better pay then who would produce the software?<o:p></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt;">
<br /></div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: 13.5pt;">All too
often we lose site of the human factors in software. It doesn't matter if
management pushes people to overwork or if it was their own bright idea to get
ahead. The result is always the same. People are just people. They are not
machines that can produce day after day without some kind of human interaction.
In the end everyone needs a life. <o:p></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: 13.5pt;"><br /></span></div>
<div style="margin: 0in 0in 0.0001pt;">
<h3>
<span style="font-size: medium;">Source</span></h3>
</div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: medium;">LIFE</span></div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: medium;"><br /></span></div>
<div style="margin: 0in 0in 0.0001pt;">
<h3>
<span style="font-size: medium;">Good Reading</span></h3>
</div>
<div style="margin: 0in 0in 0.0001pt;">
<span style="font-size: medium;"><br /></span></div>
<a href="http://www.amazon.com/gp/product/0932633439/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0932633439&linkCode=as2&tag=startiprogra-20">Peopleware: Productive Projects and Teams (Second Edition)</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=startiprogra-20&l=as2&o=1&a=0932633439" style="border: none !important; margin: 0px !important;" width="1" />
<script src="http://wms.assoc-amazon.com/20070822/US/js/link-enhancer-common.js?tag=startiprogra-20" type="text/javascript">
</script>
<noscript></noscript><br />
This was required reading when I was going to school. It is an excellent book for both programmers and managers alike.<br />
<br />
<br />
<a href="http://www.amazon.com/gp/product/013143635X/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=013143635X&linkCode=as2&tag=startiprogra-20">Death March (2nd Edition)</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=startiprogra-20&l=as2&o=1&a=013143635X" style="border: none !important; margin: 0px !important;" width="1" />
<br />
This is another great book on the human factor of software development. After reading this, I realized that I had been on several "death marches" myself.
<br/><div><br/>
<iframe src="http://rcm-na.amazon-adsystem.com/e/cm?t=startiprogra-20&o=1&p=48&l=ur1&category=musicandentertainmentrot&f=ifr" width="728" height="90" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe></div><br/>
Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com184tag:blogger.com,1999:blog-3330537307691354432.post-4750854259388885932013-04-15T20:43:00.001-07:002013-04-24T13:46:27.828-07:00Extension MethodsExtension methods in .NET are methods that can be attached to another class without changing that class. In .NET extending a class is not the same thing as inheriting from a class. Extension methods only serve as a syntax shortcut to add helper type methods to an existing type or class.<br />
<br />
<h3>
Using Extension Methods</h3>
<div>
In both C# and VB.NET you can write a static class with static members to create your own extension methods. Below is an example of an extension method called SplitByPipe that extends the system type <i>String </i>to support splitting the string by a pipe character.</div>
<div>
<br /></div>
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">class</span> StringEx</pre>
<pre><span class="lnum"> 2: </span>{</pre>
<pre><span class="lnum"> 3: </span> <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span>[] SplitByPipe(<span class="kwrd">this</span> String s)</pre>
<pre><span class="lnum"> 4: </span> {</pre>
<pre><span class="lnum"> 5: </span> <span class="kwrd">return</span> s.Split(<span class="str">'|'</span>);</pre>
<pre><span class="lnum"> 6: </span> }</pre>
<pre><span class="lnum"> 7: </span>}</pre>
</div>
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> Program</pre>
<pre><span class="lnum"> 2: </span>{</pre>
<pre><span class="lnum"> 3: </span> <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)</pre>
<pre><span class="lnum"> 4: </span> {</pre>
<pre><span class="lnum"> 5: </span> <span class="kwrd">string</span> input = <span class="str">"string1|string2|string3"</span>;</pre>
<pre><span class="lnum"> 6: </span> <span class="kwrd">var</span> result = input.SplitByPipe();</pre>
<pre><span class="lnum"> 7: </span> Console.WriteLine(result[1]);</pre>
<pre><span class="lnum"> 8: </span> }</pre>
<pre><span class="lnum"> 9: </span>}</pre>
<pre></pre>
</div>
<b>You can also extend generic methods</b>. When you create a generic extension method you must add the type parameter, in this case T, to both the method name and the <i>this</i> parameter type name. See the below example:
<br />
<br />
<div class="csharpcode" style="font-size: medium; font-weight: normal;">
<pre><span class="lnum"> 1: </span><span class="kwrd">public</span> <span class="kwrd">class</span> MyClass<T></pre>
<pre><span class="lnum"> 2: </span>{</pre>
<pre><span class="lnum"> 3: </span> <span class="kwrd">public</span> T Value { <span class="kwrd">get</span>; <span class="kwrd">set</span>; }</pre>
<pre><span class="lnum"> 4: </span>}</pre>
<pre><span class="lnum"> 5: </span><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">class</span> MyClassEx</pre>
<pre><span class="lnum"> 6: </span>{</pre>
<pre><span class="lnum"> 7: </span> <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> MyEx<T>(<span class="kwrd">this</span> MyClass<<span class="kwrd">T</span>> mc)</pre>
<pre><span class="lnum"> 8: </span> {</pre>
<pre><span class="lnum"> 9: </span> Console.WriteLine(mc.Value);</pre>
<pre><span class="lnum"> 10: </span> }</pre>
<pre><span class="lnum"> 11: </span>}</pre>
<div>
<br /></div>
</div>
<h3>
Limitations</h3>
The <i>this </i>reserved word before the first parameter of the string is required. It tells the compiler what class you are extending. <b>The <i>this keyword </i>must also be the first </b>
parameter in the parameters list
. You can add other parameters to the function but they can not have a <i>this </i>proceeding them.
<br />
<br />
<b>The class and the method must both be declared static</b>. This is a strange case where you are actually calling a static method but you usually call it using the instance of a class. If you want to call it as a static and not as an instance method than you must call it using the static class. In this case you would call <b>StringEx.SplitByPipe(input).</b><br />
<b><br /></b>
<b>
</b><b>You can not override a base method using an extension method</b>. Although the compiler will not give an error, it will not work. Methods declared in the actual class will always take precedence and the custom extension will be ignored. However, if you have an extension method with the same name as a base method but different parameters, the extension method will be called and not the base method. The method signature has to be unique not the actual method name.<br />
<br />
<b>You can only override methods</b>. C# does not provide any functionality to extend properties. The only alternative is to use the naming convention using methods: getMyProperty(...) and setMyProperty(...). That will not provide actual property syntax but it is standard naming when you can not use properties.<br />
<br />
<b>Your extension method's namespace must be included</b> in order to show up. Just including the namespace of the base class will not import the namespace of the extension method. Extension methods are often included in a seperate assembly so you would first add the external assembly as a reference and then add the using statements to your codebase.<br />
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
Why Use Extension Methods</h3>
<div>
While extension methods are in no way required to make a good .NET application they are very useful when it comes to writing utility type functions on an existing framework or even within your own code base. It is usually not considered best practice to inherit off of common and built in types like String and Integer. Doing so can make your code less portable and non-standard.<br />
<br />
It is also worth mentioning that some classes in C# are sealed so you can not extend them using inheritance and you would have to explicitly declare them as partial in order to add to the class using a partial.<br />
<br />
<h3>
When Should You NOT Use Extension Methods</h3>
</div>
<div>
Extension methods can help you to <b>avoid incrimenting a version number on a assembly</b> by allowing modification to your class outside of its actual library. MyLibrary.dll might contain the core functionality while MyLibraryEx.dll would include extensions to that library. This can make sense when the extensions are not required in the core library and they logically fit together. However, if <b>your only goal is to avoid recompiling an assembly</b> than it is not a good idea. Multiple libraries that do not go together will only serve to complicate your references and make it difficult during deployment and troubleshooting.<br />
<br />
If you are generating code using t4 or other scripting languages than a<b> partial is more appropriate</b>. A partial will give you more power and flexibility when you control the actual base class.<br />
<br />
<b>Inheritance may be more appropriate</b> if the functionality fits more into the actual core requirements of your software and are always required. For instance if you have an animal <i>super class</i> and both feline and canine <i>sub classes</i> than it would make more sense to use inheritance instead of implementing feline and canine extension methods.<br />
<br />
As with any programming feature, <b>it can be overused and abused</b>. If more of your solution is extension methods than other types of code than you may be overusing them. Generally my solutions only have a few extension methods that are used when I think the core framework should have implemented something or when it just makes the program easier to read.<br />
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
What About Before Extension Methods</h3>
Before extension methods plain old static classes were used and the programmer would just pass an instance of the class into the static method. These are often called helper methods or helper classes. Helper methods are still in use even with the introduction of extension methods.</div>
<br />
<h3>
More Tips</h3>
<div>
<ul>
<li>You can implement more than one extension method type in one class. It is possible to extend both String and Integer within the same static class.</li>
<li>There is no naming convention enforced by the compiler. Extension classes do not have to end with Ex and the file does not have to end with Ex either.</li>
</ul>
<h3>
Sources</h3>
<div>
<a href="http://msdn.microsoft.com/en-us/library/vstudio/bb383977.aspx">Extension Methods</a></div>
<br />
<h3>
More Resources</h3>
<br />
<a href="http://geekswithblogs.net/BlackRabbitCoder/archive/2013/03/08/c.net-little-wonders-extension-methods-demystified.aspx">C#/.NET Little Wonders: Extension Methods Demystified</a><br />
<br />
<br />
Updated: Generics can be extended. I removed it from the limitations.<br />
<h3>
</h3>
</div>
Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com0tag:blogger.com,1999:blog-3330537307691354432.post-19024433564814908562013-04-12T10:54:00.001-07:002013-04-23T07:38:55.801-07:00Why You Shouldn't Use Privates AnymoreFor nearly half of my career I thought that hiding member variables and methods with private and protected was one of the best ways to write better code. You have probably been taught in school or have read several well written articles of why using private makes your code better.<br />
In theory hiding the details of the class using a private can have the following benefits:<br />
<br />
<ul>
<li>Reduces the complexity of the code by <b>limiting communication between modules</b>.</li>
<li><b>Hides implementation details</b> so that you can focus on the what instead of the how.</li>
<li><b>Prevents access to dangerous variables</b> that could unintentionally cause the class to break.</li>
<li><b>Reduces the scope of a member </b>to just your class.</li>
</ul>
<br />
All though I have found that the above are true there are an equal amount of negative consequences for using private scoped members. The negative impact of this design choice, in my opinion are far worse than the actual positives involved. There are other ways to achieve the above goals without the usage of private members.<br />
<br />
<b>Limiting communication between modules</b> is a concept that comes from a <span style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1953125px;">psychologist </span>named <a href="http://en.wikipedia.org/wiki/George_Armitage_Miller">George Miller</a>. <a href="http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two#The_.22magical_number_7.22_and_working_memory_capacity">Millers Law</a> basically states that <i>human beings on average can not handle more than 5 plus or minus 2 ideas, entities or objects at one time</i>. I am always aware of this basic principle when designing both user interfaces and when coding.<br />
<br />
It is not necessary to lock the inner workings of the class up so that no one can see whats going on inside. If you opened the hood of a car it wouldn't help for them to hide the spark plugs so you couldn't see how it works. <b>Limiting communication between modules</b> and <b>hiding implementation details</b> can be achieved by using either a purely abstract class or an interface.<br />
<br />
Using interfaces to communicate between modules it turns out solves a-lot of the problems that private variables where solving. So the question is why do both? Well, it turns out that most developers have not been using interfaces for this purpose. It was not until Test Driven Development came along that private members have become the enemy.<br />
<br />
The main reason that TDD hates private members is due to its negative impact on the test-ability of a class. TDD coders like to take a class and write test code that changes variables, and dependencies in order to run automatic scenarios to verify its functionality. If members and variables are private it only serves to make unit testing harder. Due to the fact that test-ability was not a key metric in traditional software engineering methodology, this was overlooked.<br />
<br />
<b>Preventing access to dangerous variables</b> may save some headaches in some situations. However, I think that we should let the developers decide what they should or should not be accessed. If the developer is not accessing an interface and has access to the implementation than changing the wrong variable is not the responsibility of the original class creator.<br />
<br />
In practice I have seen private variables cause entire classes to be re-written when all that was needed was an override of a single member variable or a trivial function. There is no doubt that the intent in those cases was to prevent developers from tinkering with things they shouldn't be. Why are we arbitrarily deciding what should or should not be "override-able" in our base classes?<br />
<br />
If you really want to reduce the scope of a member variable than interfaces are the way to go. I don't care about the scope of a class member if it is not an interface. So let your interfaces handle communication and stop trying to force good developers from solve problems within your solutions.<br />
<br />
<br />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com2tag:blogger.com,1999:blog-3330537307691354432.post-65364448906825106392013-04-09T18:16:00.001-07:002016-03-31T14:11:24.222-07:00Do I Need a Degree to Write Software?<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaGW2trKzzMs7ut7uOzZQrIxik-iIyL2D-g1UTXG_q72aCFoF9Fyxjlmlwc3CtmBlcFsYeJ01b52hwvAUMDVxg0_J0n4WJXCwX2AHgZ_S5yIEDyzwFhrMmg1qI8_0KdwH2h29biu5puCk/s1600/hats-657140_640.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaGW2trKzzMs7ut7uOzZQrIxik-iIyL2D-g1UTXG_q72aCFoF9Fyxjlmlwc3CtmBlcFsYeJ01b52hwvAUMDVxg0_J0n4WJXCwX2AHgZ_S5yIEDyzwFhrMmg1qI8_0KdwH2h29biu5puCk/s320/hats-657140_640.jpg" width="320" /></a></div>
Many people over the years have asked me if they need a degree in Computer Science to get a programming job. Technically a degree is in not required to be a programmer. However, I believe that the degree program that I completed was invaluable to my career.<br />
<br />
Most all jobs I have applied for consider 5 years experience in the field as equivalent to a degree. I once thought that only programmers with degrees really have a well rounded background in in the fundamentals. But despite my belief in the core curriculum as minimum of skills required to be a good programmer, I have known good developers with no degree that knew all the fundamentals. I also have seen developers with excellent degrees that did not know the first thing about coding.<br />
<br />
The real asset that you get from completing a degree in Computer Science is from the actual knowledge you acquire and the guidance you get from experienced professionals that have studied the subject at length. If you just learned how to dupe the professors and you never truly learned what they were teaching than it will most likely be found out in the interview process.<br />
<i><br /></i>
<i><b>I could care less about the degree you have</b></i> when I am involved in hiring developers. Would I care about is what you know. If you managed to get to the interview and you don't have a degree than it means I don't care. What I do care about is that you have the ability to write good code and you have an understanding of everything from Computer Architecture to Software Engineering. You don't need to go to school to do that but it may help to have a structured learning environment.<br />
<br />
There are some places that will not consider non-degree developers. I find that very rare in the industry. Once you have the experience, most places will not look at the degree or lack thereof. Having said that, not having a degree could limit your options and may mean that someone else with the same qualifications and experience gets the job and you don't.<br />
<br />
If you do decide that school is just not for you than set yourself on a path to being a competent Software Professional by making your own learning plan. Because you don't have to worry about classes that are not directly related to your profession you can focus all of your energy on Computer Science Subjects. The following is a minimum for a programmer to know:<br />
<ul>
<li><b>Learn Assembly</b> - Some developers sware that learning assembly first is the best way to be a good developer. This is because all other languages just translate into binary and assembly is just a human readable form of binary.</li>
<li><b>Programming 101</b> - Pick up a bug on beginning programming in C#, VB.NET, Java or whatever language you want to use. I would suggest a strong type language for your first Language.</li>
<li><b>Object Oriented Programming</b> - OO is everywhere right now and even if you don't like it you will need to at least understand it. I don't like how OO is mixed in to basic programming classes. A good book to start learning OO is <a href="http://www.amazon.com/The-Object-Oriented-Thought-Process-Edition/dp/0672330164/ref=sr_1_1?ie=UTF8&qid=1365611818&sr=8-1&keywords=Object+Oriented+Thought+process">The Object Oriented Thought Process</a>. </li>
<li><b>Advanced Programming</b> - Once you think you have mastered basic programming then move on to a more advanced book on the same language. Go past just basic for loops and variable assignments. </li>
<li><b>Data Structures</b> - You need to implement your own data structures in order to write real world applications. Chances are that you will not actually write these data structures but you will use 3rd party implementations of hash tables, linked lists, stacks and tree structures etc. You don't want to learn this on the fly and it should be mastered before attempting more advanced programming subjects.</li>
<li><b>Computer Architecture</b> - Learning what the underlying workings of a computer can help when programming. You don't need to be an electrical engineer but a basic knowledge of and gates, boolean logic, assembly language etc will help you down the road.</li>
<li><b>Client Server Architecture</b> - Learn the ins and outs of how the web works. Even if you don't want to be a web developer, everything is online now days. You need to know how to call web services and hook into online api. Understand how TCPIP works and know "How the Web Works".</li>
<li><b>Object Oriented Design</b> - Get a good book on pure object oriented design and become best friends with it. Take it to lunch and hang out with it when you get off of work. The reason is you will be using it everywhere in software. You can program with only a shallow understanding of OO but a deep knowledge will let you use 3rd party tools and api's to there max potential. </li>
<li><b>Traditional Software Engineering</b> - Pick up an older book on software engineering and spend a good amount of time mastering the subject. Looking on the internet is probably not going to help here. <a href="http://www.amazon.com/Structured-Design-Fundamentals-Discipline-Computer/dp/0138544719/ref=sr_1_2?s=books&ie=UTF8&qid=1365613245&sr=1-2&keywords=Edward+Yourdon+Structured">Structured Design</a> is a must read in my opinion. The software industry is really split three ways between companies who use no methodology, ones who use traditional approaches, and ones who use Agile processes. </li>
<li><b>Agile Development </b>- Agile development is used heavily. Knowing what you are talking about in this area is important. Agile and traditional techniques but heads. Even if you think agile is the only way to do things its best to have a full understanding of the traditional techniques. This is because Agile is really takes a-lot from the lessons of traditional engineering.</li>
<li><b>Project Management</b> - Even though you are a programmer and may never manage a project you need to know how software should be managed. Software Project Management is radically different from traditional Management. There is a range of techniques so don't just take one as law. The <a href="http://www.amazon.com/Mythical-Man-Month-Software-Engineering-Anniversary/dp/0201835959/ref=sr_1_1?s=books&ie=UTF8&qid=1365612586&sr=1-1&keywords=Mythical+Man+Month">Mythical Man Month</a> is an absolute must in my opinion. Also read books on agile project management.</li>
<li><b>Database Management</b> - Although its helpful to learn SQL statements you need an academic book on the fundamental design of databases. This should teach you how to spot a bad database and how to fix it. It will help you make decisions on how to write your own tables etc. This is good as a last course because engineering plays into this.</li>
<li><b>User Experience </b>- There are many books written on ui design and user experience. I would suggest reading several of them. In addition there are standards written by Microsoft and other large companies. Take advantage of millions of dollars worth of research and read what they have to say. There is nothing worse than a bad user interface to a software package. Even if you don't make user screens this can help you write better software.</li>
<li><b>Learn a core API/SDK</b> - While you are trying to master other subjects make sure to learn a core industry api for what you want to develop. For me this is a user interface api such as winforms/ASP.NET or WPF. However, you may not be writing user interfaces maybe this means a graphical api like GTK or DirectX. Perhaps it means diving deeper into low level driver programming or mastering an SQL variant.</li>
</ul>
Mastering a subject takes more effort than just casual reading. Don't just read a book but study it. This means reading the same chapter over and over. Quizzing yourself on the subject. Learning does not take place within a short period of time. Read a book all the way and then spend a set amount of time really mastering what it says. Programming is learned by doing and not by reading. If the book has practice exams and exercises do them all. I can guarantee that the real world will have harder tests than the ones in your book.<br />
<br />
While you are trying to master the art of programming you should be looking for an entry level position. If you can't find one than start your own open source project or even a project for money on your own. Even if you fail or get fired don't give up. I wrote my first program when I was 15 before I went to school. It is that experience that has helped me to get into the profession.<br />
<br />
You should be looking to fulfill that 5 years of experience. Pay is not that important when you first start out. Experience matters, if you can get yourself in the door with a company than hold on until you feel you can get hired elsewhere.<br />
<br />
related blogs:<br />
<a href="http://www.andymoore.ca/2013/03/do-you-need-a-degree-for-game-dev/">do you need a degree for game dev</a><br />
<br />
<br />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com11tag:blogger.com,1999:blog-3330537307691354432.post-16624616058766131982013-04-08T15:53:00.001-07:002013-04-11T18:58:47.641-07:00Should I Take Programming Burnout Seriously?<h3>
Should I Take Programming Burnout Seriously?</h3>
<b><span style="font-weight: normal;"> Yes!<b> </b></span></b><span style="font-weight: normal;">If you are suffering </span><b><span style="font-weight: normal;"> burnout take it very<b> </b></span></b><span style="font-weight: normal;">seriously as it could cause medical problems and it could be a sign of more serious mental illnesses. The advise that I give on the subject is in no way to be considered "professional advise". If you are having issues with burnout I suggest that you seek help from a professional.</span><br />
<br />
<span style="font-weight: normal;">You could actually be suffering from severe depression.</span><b><span style="font-weight: normal;"> </span></b><span style="font-weight: normal;">According to the Mayo Clinic:</span><br />
<span style="font-weight: normal;"> </span>Ignored or unaddressed job burnout can have significant consequences, including:
<br />
<blockquote class="tr_bq">
<ul>
<li>Excessive stress</li>
<li>Fatigue</li>
<li>Insomnia</li>
<li>A negative spillover into personal relationships or home life</li>
<li>Depression</li>
<li>Anxiety</li>
<li>Alcohol or substance abuse</li>
<li>Heart disease</li>
<li>High cholesterol</li>
<li>Type 2 diabetes, especially in women</li>
<li>Stroke</li>
<li>Obesity</li>
<li>Vulnerability to illnesses</li>
</ul>
</blockquote>
<h3>
<b><span style="font-weight: normal;"></span></b></h3>
<span style="font-weight: normal;"></span><br />
<h3>
<b><span style="font-weight: normal;"></span></b></h3>
<h3>
</h3>
<h3>
What Causes Burnout?</h3>
The biggest cause of burnout is you. You are most likely an overachiever that wants nothing more than to prove to yourself and to others that you are a great developer. Its this can do attitude that most likely made you a highly skilled and a highly sought out software professional. However, if you don't take care of yourself than who cares if you are an awesome developer. <br />
<br />
<h3>
What Can I do To Prevent Burnout</h3>
In order to prevent burnout and for that matter other mental disorders you need to maintain balance in your life. It may have been fine when you where 15 to program until 3am and through the weekend. But...you were not a full time programmer and you had other things to keep you busy. Its not good for anyone to stare at strange symbols all day and all night. You need to maintain balance in your life by:<br />
<ul>
<li>Involving yourself in a hobby</li>
<li>Take a vacation</li>
<li>Hang out with people</li>
<li>Get enough sleep</li>
<li>Get a life</li>
</ul>
A good way to maintain balance is to <b>involve yourself in a hobby</b>. When I got severely burnout I started gardening, began bowling, took-up reading ( non-programming books ) and I began learning Spanish. The best part about taking up a hobby is if you do get burned out you can just get involved in your hobby and not worry that programming is no longer fun to you.<br />
<br />
If you started working as a programmer than it is no longer something you do as a hobby "for fun". No matter what kind of project you are doing on the side or how much fun you think it is. So just say no to programming at home. You want to write something more interesting find another job.<br />
<br />
If its been a while than you need to<b> take a vacation</b>. No programming computers on your vacation time either! Take it with real people not virtual ones. Believe me its a-lot cheaper to pay $3,000+ on a week vacation than it is to have to switch jobs because of burnout.<br />
<b><br /></b>
<b>Hang out with people</b> more often to keep the non-computer social interaction up. I know that people are much harder to communicate with than computers and you may feel socially awkward and just want to get back to the old keyboard and monitor but hangout with people anyways. If you must find people as geeky as you to hang out with. Or even find a girl that will put up with you.<br />
<br />
<b>Get some sleep</b> for crying out loud. Pulling all nighters is not really productive. Your brain actually needs sleep in order to function. Have you ever noticed that you solve difficult problems after getting a good nights sleep and coming back to the problem.<br />
<br />
<b>Get a Life!</b> There is life outside of work so go live it. Do something fun for a change. I know you think programming is fun but its really not. Spending time with your friends and family, going to a ballgame with your niece or nephew, volunteering is fun. So get a life and don't drive yourself into an insane asylum trying to be a "master programmer".<br />
<br />
<h3>
Am I too Young to Burnout?</h3>
There is no age restriction when it comes to burnout. I was severely burned out after only 2 years in the profession and had to take six months off from programming before I want to do it again. I thought that the urge to develop software was gone for good. But in fact I have been programming for 9 years after that experience and my desire to programming came back in full. <br />
<br />
<h3>
What do I do if I can't Program Computers?</h3>
If you are completely burned out from programming you may be asking yourself how you are going to make money in the future. I know that you may be thinking that programming will never be something you ever want to do again but the desire to program computers will most likely come back. Even though it feels permanent it most likely is not.<br />
Having said that, you will need to do one of the following: <br />
<ul>
<li>Take a <i>leave of absence</i> </li>
<li>Switch to a different role in the same company</li>
<li>Reduce your work load at your current job</li>
<li>Find a temporary source of income while you recover.</li>
<li>Find a permanent new profession </li>
</ul>
If I had to choose I would pick a <b>leave of absence</b>. This may allow you to keep your position while you recover. Don't feel that you have to come back too soon and don't give into pressure from your company. You may find that you are more valuable than you thought. You can just say its a personal matter that you have to attend to. You may find it better to just flat out tell your boss the situation. If it is a seasoned software development team they may know about creative burnout and know what to do. Whatever you do do it gracefully and don't burn any bridges.<br />
<br />
You could inquire about <b>switching to a different role</b> within the same company. You may just be burned out on the type of programming you are doing or you may just be burned out on the coding end. Perhaps your company has different roles that you could be useful in. Even though you don't churn code anymore the company may find it beneficial to retain you as say a QA guy while you help with the transition of another developer.<br />
<br />
If your are burned out than you need to <b>reduce your work load</b>. This is true weather you switch roles or switch companies all together. Burnout occurs when you are overworked and it most likely is self-inflicted. Let your manager know you are overloaded and think you can't handle a large work load right now. I know if you are an over achiever, like me, this is very difficult to say but it could save your job in this case.<br />
<br />
If you think is better to move on than you need to find a<b> temporary source of income</b>. Don't worry about it being a permanent career path just get some money coming in. If you are single this is pretty easy, move in with your parents or find a good friend to live with for a while so you can deal with a reduced salary. When the desire to code comes back you can start looking for a new job then.<br />
<br />
I would only advise finding a <b>permenant new profession</b> after taking a substantial period of time off. After a few months of not coding pick up a compiler and see if you want to code again. If you don't want to than wait a little longer. Some programmers take over a year off before the desire comes back. Burnouts can range in severity of a <i>just bored </i>to <i>in need of medical attentio</i>n.<br />
<br />
references:<br />
<a href="http://programmers.stackexchange.com/questions/156073/am-i-too-young-to-burn-out">Stack-exchange: Am I too young to burn out?</a><br />
<a href="http://www.mayoclinic.com/health/burnout/WL00062/NSECTIONGROUP=2">Job burnout: How to spot it and take action</a><br />
<br />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1tag:blogger.com,1999:blog-3330537307691354432.post-36098009046213549702013-04-08T15:15:00.001-07:002013-04-08T15:15:10.536-07:00Hail KnuthAfter committing some very bad programming sins I felt bad enough to confess them to a fellow developer. After hearing my confession he compelled me to say 100 "Hail Knuths", and to sin no more. <br />
<br />
<i>Hail Knuth, full of experience, the source is with thee; blessed art thou amongst software engineers, and blessed is the fruit of thy methodologies, common sense.<br />Holy Knuth, Father of Design, pray for us hackers, now and at the hour of our death march. Amen.</i><br />
<br />
I also found it lifted my spirits to say this when faced with a horrible list of bugs in really bad code:<br />
<i><br /></i>
<i>Yea, thou I walk through the endless call stack of death, I will fear no bugs; for I understand system design and I know that this is not my fault and I already have my resume online.<br />Amen</i><br />
<br />
I have several of these passages that I wrote from taking bible versus and switching the the subject matter to programming. I have hesitated to post them from fear of it being construed as some type of disrespect towards Christianity. Nothing could be farther from the truth as I am a practicing Christian myself.<br />
<br />
I also thought it might not be a good thing to mix religion and computer science together. Not that I am ashamed of my faith at all but because its so nice to have an outlet where religion is not a topic. I think its funny how much ideology is involved in software development. We hold what some people say as almost biblical. Arguing with Knuth is probably as close to blasphemy as you can get in the programming world. <br />
<br />
<br />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1tag:blogger.com,1999:blog-3330537307691354432.post-88994619821397820662013-04-06T17:16:00.003-07:002021-06-18T08:25:39.583-07:00Why Estimates are WorthlessSoftware estimates are most often completely worthless and a waste of time for everyone involved. Its a waste of time for the manager because the estimates that they get are usually shallow and only reflect what the manager wants to happen. Its a waste of time for the developer because of countless hours pondering what something will cost and why it would cost that, only to find out after completing the task how many things he/she missed.<br />
<h3>
</h3>
<h3>
The Ego </h3>
Estimation is in the realm of the what ifs and and maybe ifs and is usually grounded more in guesswork than in science. Egos often get in the way of good estimates when the programmers are involved. As for managers the pressure to deliver features in a certain amount of time instead of getting an accurate view of how much time a task will take.<br />
<br />
<h3>
The Unknowns </h3>
One of the big differences between Software Construction and physical construction is the amount of unknown involved. Out of all the different software projects I have been involved in, not one of them was exactly the same or even close to being the same. In fact most all of them involved a drastic change in technologies and in business domain. This sort of shift makes it difficult to predict what is going to happen in the project. Inventory applications have different kinds of problems than shrink wrap CAD programs for instance.<br />
However, when I had my house built I asked how long it would take. I was given a reply that it always takes between 2 and 4 months and they are pretty sure it was going to take 3 months. It took exactly 3 months to complete. The reason they could be so accurate and so fast at putting my house up was not that it was easy to build a house but because there were really very few variables and unknowns in building a house. They had built several of these houses and they were the same house with minor changes that made my house look a little different from another house down the road that they had built. Experience building a house almost identical to mine is what made them so accurate at predicting how long it would take to complete mine.<br />
<br />
<h3>
Experience </h3>
I would submit to you that this type of experience for building software is almost never going to happen. However, professionals who have been working in the industry find it difficult to admit to upper managers that they do not have enough experience in the areas that they are estimating to give an accurate estimate. Often times developers understand the problem is lack of experience but are too afraid or think it would be foolish to inform their managers.<br />
One of the biggest reasons for lack of experience is the size of the knowledge base needed to develop software. The size of the tools we use is enormous and they are adding to them every day. What you may have picked up last week can be eliminated by new features and fixes to the tools. Good developers learn how to be good at figuring out 3rd party and built in tools rather than memorizing them and mastering them.<br />
<br />
<h3>
The Dynamic Nature of Programming Software </h3>
I have never been a plumber but I imagine that installing plumbing in a new house remains the same for some time maybe even years before advances in technology makes them learn new things. I doubt that in the middle of fixing a sink they realize the pipes that were top of the line 6 months ago are obsolete now and need to be completely removed and replaced.<br />
The dynamic nature of the business makes mastering programming virtually impossible for us mere mortals and therefore also impossible to predict.Estimates without padding to account for unknown api and technology shifts are naive to say the least and foolish and stupid to say the most. For this reason I have seen frustration on the side of both project managers and programmers alike. The programmers know why its a waste of time but the reasoning makes them sound like they don't know the profession.<br />
<br />
<h3>
Managerial Tactics </h3>
For a-lot of managers estimates are just a way of cracking a whip and motivating team members with a deadline. It is said that "If you give someone a week to complete a task it will take a week if you give them a day it will take a day." Unfortunately this is a traditional management technique that fails to realize one thing. We are not building cars or cookie cutter houses. No amount of motivation is going to get a developer to write a program in 2 days that takes a week. One of the biggest problems is no one actually knows a realistic time for the task to be completed. So in an attempt to motivate employees an laughable estimate is put into law. Because there is no possibility to hit the deadline the developers get demotivated and start ignoring all deadlines.<br />
<br />
<h3>
Psychics and Crystal Balls</h3>
Think twice before pushing for estimates on all of your projects. There are alternatives to controlling budget other than trying to predict the future like you are a psychic with a crystal ball. Instead try to reduce the scope of your project and reduce the risk. In other words do less and deliver on time. This has been a corner stone of the Agile process and I would say its one of the main reasons that Agile has been successful. Stop wasting your time going to software fortune tellers and just manage the project right. Don't get out out of control with features and make sure you are releasing features on a regular short cycle.<br />
<br />
<h3>
Good Reason for Estimates</h3>
I understand that some projects are different. Some projects involve a lot of upfront analysis and careful planning. Sometimes we are trying to determine if a project is worth it or if we should try something else. Fixed bid projects for contractors/consultants cause a hurdle for the project and the powers at be and large corporate policies can keep projects from working on an incremental approach. Just remember that most developers and managers just can't estimate. Most of the time it is just a waste of time even if you think there is a good reasons to estimate. It just gives you a false sense of security. And the way software projects work, you probably wont realize the project was never going to be done anywhere close to the estimate until the deadline is almost done and everyone looks up and says "How the hell are we going to be done next week?". In the end even if you need it to work it just doesn't.<br />
<br />
<br />
<br />
<br />
<br />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1tag:blogger.com,1999:blog-3330537307691354432.post-5914116756374237892013-04-02T10:57:00.000-07:002013-04-17T14:48:50.055-07:00How to Estimate Software the WRONG Way<h3>
Negotiate with the Software Developers</h3>
One of the best ways you can screw up when making an estimate is to try to negotiate the time frame with the developers. Programmers generally don't realize they are being negotiated with so this is easy pickings. They actually have no leeway in their estimates and end up telling the manager what she wants to hear.This makes matters worse because now instead of having an idea of when something is going to be done you have a make believe world based on what you want to happen instead of what will really happen. Trust me if a developer says something is going to take a week it is more likely to take longer time than it is to take less time.<br />
<br />
<h3>
Don't Cut any Features to Hit a Deadline</h3>
<div>
If you really want to muck things up stand fast on your features and put it on the shoulders of the developers to deliver what you want no matter how extravagant it is. If you don't cut features than you can safely say that your estimate is a fantasy. Features are the biggest variable in the estimation process so if you want your budget to go haywire refuse to cut anything. I would even suggest holding on to the useless features that nobody will ever use just because you want it.<br />
<br /></div>
<h3>
Demand Results</h3>
<div>
The best thing to do is to walk in to the estimation meeting with the developers slam your fist on the table and demand results. For better effect you might consider acting like a two year old and roll on the ground kicking your legs and screaming "I want it! I want it!" Programmers with kids will get it and know you are screwing up the estimates on purpose. Maybe they will even help you with statements like "I have no clue how to do that but it sounds pretty easy. I think about an hour.".</div>
<div>
Also consider telling the developers that "If they don't do it within your unreasonable time frame they can find a new job". That will ensure that the good developers go ahead and contact their buddies in other software firms and secure a better paying job with a better work environment. You will be left with the bad developers that the rest of the team was carrying. They are great pawns to point the blame when the project goes downhill.<br />
<br /></div>
<h3>
Don't Prioritize</h3>
<div>
Whatever you do don't set priorities. Setting priorities may mean that the most important features are done first and the least important features will not be delivered. You probably want the opposite result so leave the developers in the dark about what takes priority. Have some fun with it and confuse them by telling them that having a window animate across the screen is more important than the database being created.<br />
<br /></div>
<h3>
Make a Moving Target</h3>
<div>
As if software requirements don't move by themselves enough, you can help by changing things that don't need changing. Just walk in one day and tell your developer you don't like Silverlight and you want him to do it in ASP.NET instead. Here are some good ideas on what to change to muck things up good:</div>
<div>
<ul>
<li>Constantly change your mind on what you think the UI should look like. </li>
<li>Change terminology and add/remove form fields constantly. Your team will have to either update their code to change to your new lingo or they will have to live with you saying "Manager" and the code says "Team Leader". That will catch the OCD programmers and waste a-lot of their time.</li>
<li>Wait until a form is done and meets all of your requirements and then move arbitrary fields around. Decide at the last minute that you want a "search feature".</li>
<li>Large architectural changes with no added value are best. Just tell them I want to switch to MVC and I want everything to be threaded no matter what it is. The later in the project you do this the better.</li>
</ul>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
<br /></h3>
<h3>
Just add More "Team Members" to Slow Down the Project</h3>
<div>
If you see more time estimated than you have in the budget just add more developers. This is a great way to screw up an estimate because naive IT managers think you are fixing a problem. In reality only so many developers can go into a project. More developers can take longer to do the same thing a smaller more cohesive team can. Also, if you have a long standing team lets say 6+ months together speeding up a new developer is going to cost you 2-6 months of turnover time that you can act like you didn't know about. </div>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
<br /></h3>
<h3>
Confuse Estimates with Goals</h3>
<div>
When a developer says he thinks something is going to take 2 weeks just act like he is not a team player. You can easily turn an estimate into a company wish list by intimidating the programmer into changing his estimate to your business goal. This should make your boss happy while you look for a new job. When the project gets canceled because you couldn't meet your budget then it's probably time to look for another project to screw up in a different company.</div>
<div>
Combining your goals with your estimate is bound to really confuse everyone at the end of the project you can squarely point at the developers and say "They can't estimate software!" In reality you know that you made the estimate and manipulated them into agreeing. </div>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
<br /></h3>
<h3>
Do the Estimate Yourself</h3>
<div>
Programmers are just trying to confuse you with difficult to understand technical "facts". Act like you have a clue about what something will take to do based on how hard it looks to you. It takes discipline to ignore a developer when he tells you point blank that it just appears easy because you don't understand the technical difficulties. For Example:</div>
<div>
If you want to change the background color of a button. Act like the developer doesn't know what he is talking about when he says "That will take re-creating the entire control from scratch and take at least 3 weeks." You can respond by saying something to the effect of "Don't try and confuse me with tech speak. Everyone knows you can change the background color of a button within a few minutes".</div>
<div>
We all know that subtlety is every developers weakness so instead of just telling him you think it's easier give him blank stares and act pissed off that it will take that long. Eventually he will cave and agree to change the realistic estimate based on his prior experience and expertise into a summary of your business goals. Most of the time he is thinking of ways of getting his time back by adding more estimation time to other tasks. This works to your advantage because now it's impossible for anyone to know which tasks take longer.<br />
<br />
<h3>
Restructure the Team</h3>
</div>
<div>
Many times when a baseball team is getting smeared by another team with little chance of a comeback then both or just the loosing team will have the players switch out of the positions they are good at as a fun way of saying this game is lost but let's have some fun. The shortstop may play left field the catcher might be pitching and the pitcher could be in right field.<br />
So because you know they will never actually hit any of the fantasy dates on paper why not shift team members into roles they are not good at. Shift the back-end developer to the front end and see if they can follow each other's work. Maybe the QA guy can start programming about boxes because it's a pretty routine task.<br />
For an even more amusing effect forbid communication within the team and declare that they should be coding every hour that they are at work. If you see two team members "communicating" act like they are sitting in a break room wasting time like the other employees do.</div>
<div>
<br /></div>
<h3>
Assume Programmers are Superhuman</h3>
<div>
After it has been discovered that your estimates are completely unrealistic than declare that your development team has superhuman strengths. They can:</div>
<div>
<ul>
<li>Work through Holidays</li>
<li>Work weekends</li>
<li>Have no need for social interaction or Entertainment</li>
<li>Work an extra 24-72 hours in a month because you calculated every month as 31 days to make the schedule work.</li>
<li>Using only will power and a-lot of soda write 10000 lines of code in two hours to "Save the Company". Because obviously the company will go bankrupt without that window animation.</li>
</ul>
One of the positives that comes from this is that developers that were actually good will either quit or go insane either way they lose all credibility when it comes to finger pointing. You can say "It's too bad Joe went crazy. That's probably why he couldn't do something simple like change the background color of a button".</div>
<div>
Married developers will quit because their wives won't put up with your crap anymore. Single developers will quit because they live with their Mom anyways and can just play video games until they can find a better gig.</div>
<div>
This will leave you with the rare exception of programmers that either are loyal to you until the ship sinks or have a good sense of humor and think it's funny to watch managers walk around screaming quotes from Mythical Man month and not know it. Try shouting ".NET 4.5 is a silver bullet or "If it takes 1 programmer a month it should take 5 programmers 1/5 of a month".</div>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
<br /></h3>
<h3>
Don't Read about Estimation and Project Management</h3>
<div>
The worst thing you can do is learn how to estimate from people who have been in the industry for 20+ years and have written a book on their experiences. Act like you know what you are doing even though you have never hit a deadline. If you know who Knuth and Fredrick Brooks are then you will have a harder time screwing up estimates.</div>
<div>
Also, please repeat the most common mistakes that programmers are taught in Software Engineering 101 and act like it's a brilliant plan. Run in the room say "We are way behind we need to hire 10 new developers right now." If you can get the exact quote out of Mythical Man month on what a bad project manager would say it would be best. Again seasoned developers will get the joke and know to move on to a real software company.<br />
<br />
<h3>
Related</h3>
<div>
<a href="http://startingdotneprogramming.blogspot.com/2013/04/why-estimates-are-worthless.html">Why Estimates are Worthless</a></div>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
<br /></h3>
<h3>
Recommended Reading</h3>
</div>
<a href="http://www.amazon.com/gp/product/0201835959/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0201835959&linkCode=as2&tag=startiprogra-20">The Mythical Man-Month: Essays on Software Engineering, Anniversary Edition (2nd Edition)</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=startiprogra-20&l=as2&o=1&a=0201835959" style="border: none !important; margin: 0px !important;" width="1" />
<br />
<a href="http://www.amazon.com/gp/product/B00B9ZD20K/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00B9ZD20K&linkCode=as2&tag=startiprogra-20">Software Estimation: Demystifying the Black Art (Best Practices (Microsoft))</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=startiprogra-20&l=as2&o=1&a=B00B9ZD20K" style="border: none !important; margin: 0px !important;" width="1" />
</div>
Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com5tag:blogger.com,1999:blog-3330537307691354432.post-73960134511427598512013-03-27T11:11:00.000-07:002013-04-10T20:54:32.360-07:005 Tips for Landing a Programming Job<h3>
1 Get a Recruiter</h3>
Technology recruiters are everywhere and they do not cost you a dime. Its a free service to you. Recruiters charge the employer for the service of finding the right talent to fit their organization. Many employers do not desire or do not have the time and energy it takes to find a candidate for the hiring process. In fact many companies do not consider candidates outside of a recruiter. If a recruiter wants to charge you money do find you a job then it is a scam, run away.<br />
Recruiters are also great information sources for the market place. They can tell you if your asking price is too high or why you were turned down for a job. They can also tell you what technologies are hot and are more likely to hire.<br />
<br />
<h3>
2 Participate in a User Group</h3>
<span style="font-weight: normal;">Look for a user group in your area and join. You should find user groups that meet about the technologies you want to get hired for. User Groups are a great place to network with other developers and project managers. Its a good way to get your foot in the door and actually find employers that are looking. You can also put it on your resume that you regularly attend a user group for say Visual Studio or MS SharePoint.</span><br />
<br />
<h3>
3 Throw a Large Net</h3>
Throw a large net means you need to get your resume out as many places as you can. Give it to your friends that are already hired. Look for job postings on company websites. Post your resume on Monster.com etc. I once landed a job that was only listed on Craigslist. The more companies that get your resume the more likely you are to get an interview. But do not apply for jobs that you clearly do not qualify for or that do not make a good fit for you.<br />
<br />
<h3>
4 Research the Employer </h3>
Research and be able to discuss the company that your are interviewing for. When you get the interview spend a good amount of time researching the company that you want to work for. Learning the technology they use is important but make sure that you know something about what they are doing. Do some reading on Wiki and pick up some books about the industry. Study the company website and know what its business goals are.<br />
Are they making an inventory system? Find some literature about inventory management. Employers are guaranteed to ask you non-programming industry specific questions and how well you answer these questions is guaranteed to set you apart from the other candidates.<br />
<br />
<h3>
5 Tell them You Want the Job</h3>
If you can communicate to the employer that you want the job then it will no doubt increase your chances of getting hired. You may be putting non-verbal signals that you are not interested in the position or you may not seem to be excited about the position. Often when you are nervous your body is sending signals that you do not intend to send. The best way to offset this is to be prepared to tell them how much you are excited about the job. "I am very excited about the position its exactly what I am looking for." or "I have really been wanting to get into custom web design." are good examples. This is especially important in small companies. Start-ups are more likely to seek out candidates based on their drive and interest over pure technical skills.Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1tag:blogger.com,1999:blog-3330537307691354432.post-18807387031537444892013-03-26T14:28:00.002-07:002013-03-26T14:53:30.177-07:00Dijit D3 Custom Dashboard Part 2<h3 class="post-title entry-title" itemprop="name">
Adding Widgets</h3>
<div class="post-title entry-title" itemprop="name">
The technique for adding widget is straightforward enough. Simply add another div element with a drag and drop source as a widget gallery for adding widgets to your dashboard.</div>
<div class="post-title entry-title" itemprop="name">
<br /></div>
<pre><span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">id=</span><span style="color: green;">"WidgetGallary"</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">class=</span><span style="color: green;">"WidgetCaption"</span><span style="color: #4444ff;"><b>></b></span></b></span>Widget Gallery<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">class=</span><span style="color: green;">"WidgetSource"</span> <span style="color: #2040a0;">data-dojo-type=</span><span style="color: green;">"dojo.dnd.Source"</span> <span style="color: #2040a0;">accept=</span><span style="color: green;">"Widget"</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">id=</span><span style="color: green;">"Widget1"</span> <span style="color: #2040a0;">class=</span><span style="color: green;">"dojoDndItem Widget"</span> <span style="color: #2040a0;">dndtype=</span><span style="color: green;">"Widget"</span><span style="color: #4444ff;"><b>></b></span></b></span>Widget 1<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">id=</span><span style="color: green;">"Widget2"</span> <span style="color: #2040a0;">class=</span><span style="color: green;">"dojoDndItem Widget"</span> <span style="color: #2040a0;">dndtype=</span><span style="color: green;">"Widget"</span><span style="color: #4444ff;"><b>></b></span></b></span>Widget 2<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">id=</span><span style="color: green;">"Widget3"</span> <span style="color: #2040a0;">class=</span><span style="color: green;">"dojoDndItem Widget"</span> <span style="color: #2040a0;">dndtype=</span><span style="color: green;">"Widget"</span><span style="color: #4444ff;"><b>></b></span></b></span>Widget 3<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">id=</span><span style="color: green;">"Widget4"</span> <span style="color: #2040a0;">class=</span><span style="color: green;">"dojoDndItem Widget"</span> <span style="color: #2040a0;">dndtype=</span><span style="color: green;">"Widget"</span><span style="color: #4444ff;"><b>></b></span></b></span>Widget 4<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
</pre>
<hr />
<span style="font-size: xx-small;"><i>syntax highlighted by <a href="http://www.palfrader.org/code2html">Code2HTML</a>, v. 0.9.1</i></span><br />
<br />
<a href="http://jsfiddle.net/jmwnD/7/embedded/result/" target="_blank">Adding Widgets (JS Fiddle) </a><br />
<br />
The assumption is that the widgets will be added to the <i>widget gallery</i> using server side code. However, client side code and AJAX is also a possibility. You will need to keep track of what widgets are in the gallery and what widgets have been added to a region in the dashboard.<br />
For each widget you want to store <i>RegionName</i>, <i>WidgetName</i>, and <i>WidgetId</i>. The RegionName would be Gallery if it has not been moved to a region yet.<br />
<h3>
<b>Resizing Regions</b></h3>
Adding regions is even easier than adding a widget gallery. By adding the dojo property <b>splitter=true </b>as shown below you can allow regions to be re-sized with splitters.<br />
<br />
<div style="text-align: left;">
<pre> <span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">dojoType=</span><span style="color: green;">"dijit.layout.ContentPane"</span> <span style="color: #2040a0;">data-dojo-props=</span><span style="color: green;">"splitter:true"</span> <span style="color: #2040a0;">id=</span><span style="color: green;">"DashboardTop"</span> <span style="color: #2040a0;">region=</span><span style="color: green;">"top"</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">div</span> <span style="color: #2040a0;">class=</span><span style="color: green;">"WidgetSource"</span> <span style="color: #2040a0;">data-dojo-type=</span><span style="color: green;">"dojo.dnd.Source"</span> <span style="color: #2040a0;">accept=</span><span style="color: green;">"Widget"</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
<span style="color: #2040a0;"><b><span style="color: #4444ff;"><b><</b></span><span style="color: #2040a0;">/div</span><span style="color: #4444ff;"><b>></b></span></b></span>
</pre>
</div>
<hr />
<span style="font-size: xx-small;"><i>syntax highlighted by <a href="http://www.palfrader.org/code2html">Code2HTML</a>, v. 0.9.1
</i></span><br />
<br />
<a href="http://jsfiddle.net/TGD8X/2/embedded/result/"><i>Resize Widgets (JS Fiddle)</i></a><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7lKTdMJ5GedStxpNyLqRkH3uy1rnGHJAThYCPSPeza3mICSqks0-ZrwRBFsgCW6OmYMd4cXmlkRnF6UR_kI5O1c_gzs_KC1WYw-HDoxjSCF5sxCVvLVByzI1j10WP1-YrHUMCIMFNQYI/s1600/dashboard4.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Dashboard using dijit" border="0" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7lKTdMJ5GedStxpNyLqRkH3uy1rnGHJAThYCPSPeza3mICSqks0-ZrwRBFsgCW6OmYMd4cXmlkRnF6UR_kI5O1c_gzs_KC1WYw-HDoxjSCF5sxCVvLVByzI1j10WP1-YrHUMCIMFNQYI/s320/dashboard4.png" title="Dashboard" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><i>Dashboard with Widget Gallery</i></td></tr>
</tbody></table>
The above screenshot shows the dashboard app with the widget gallery and splitters to re-size the regions. Next time I will show how to switch between dashboard layouts.<br />
<br />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1tag:blogger.com,1999:blog-3330537307691354432.post-83029092804586812432013-03-22T11:48:00.000-07:002013-03-27T10:03:58.824-07:00Dijit D3 Custom Dashboard Part 1In this series I am going to show you how to build a custom dashboard applications using dijit for the ui controls, ajax calls for data acquisition and d3 for charting and graphs.<br />
For the layout I am going to use a BorderContainer control in the dijit library. The BorderContainer is very good at layouts that would be difficult to pull of with just html and client side code. It has a splitter control that I will go over in another post.<br />
<br />
<br />
<a href="http://jsfiddle.net/bK7m5/12/embedded/result/" target="_blank">Dashboard layout using dijit Border Container Widget (Js Fiddle)</a><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcDSwoch-fBrQIx_f2D0cJfMjwHQ3csZa7O4AhxOzW4GlwDdsRTSjR0cvF6SJVqElrKr9206v1frzPKXBE4SPgOlEQ74MFkKa6ipQWUVXs4kZQNySMJ65lpfDMK46UXJh3WGApBcr2Gjg/s1600/Dashboard2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcDSwoch-fBrQIx_f2D0cJfMjwHQ3csZa7O4AhxOzW4GlwDdsRTSjR0cvF6SJVqElrKr9206v1frzPKXBE4SPgOlEQ74MFkKa6ipQWUVXs4kZQNySMJ65lpfDMK46UXJh3WGApBcr2Gjg/s320/Dashboard2.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Basic Layout</td></tr>
</tbody></table>
After you have the border container in place you can add your widgets and make them drag-able from region to region. In order to add drag and drop functionality to the dashboard each region must contain a dojo.dnd.Source widget. The Source widget acts as both the source of a drag-able widget and as a destination. The Source widget has to have an accept attribute with the name of the class of widgets it will accept as a drag item.<br />
<br />
<a href="http://jsfiddle.net/KenParkerJr/jmwnD/4/embedded/result/" target="_blank">Dashboard with added drag and drop widgets (Js Fiddle)</a><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhceWtRndjTgsWgyFEhPpdvwwXAQZt3nXsWKdkdhlrU7goU5GjVBtH-Ds02ozCKSGF3rbeRXNsR3AVHSZ-uklZOKUfBBj5wjQz45VY4_xMcwDsRkWVZ8qY_E6Jq4FN37tpzZ8pny_uuuG8/s1600/Dashboard1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Dashboard" border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhceWtRndjTgsWgyFEhPpdvwwXAQZt3nXsWKdkdhlrU7goU5GjVBtH-Ds02ozCKSGF3rbeRXNsR3AVHSZ-uklZOKUfBBj5wjQz45VY4_xMcwDsRkWVZ8qY_E6Jq4FN37tpzZ8pny_uuuG8/s320/Dashboard1.png" title="Dashboard" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Dashboard with drag-able widgets</td></tr>
</tbody></table>
<br />
Right out of the box dojo contains very rich support for drag and drop. When you drag an item it will automatically show you an avatar of the item you are dragging. You can drag items with in the same container with out any additional code.<br />
<br />
Next time I will talk about adding and removing widgets from the dashboard and how to resize regions.<br />
<br />
<a href="http://startingdotneprogramming.blogspot.com/2013/03/dijit-d3-custom-dashboard-part-2.html">Continue to part 2</a><br />
<br />
<br />
<br />
<br />Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com0tag:blogger.com,1999:blog-3330537307691354432.post-21638925282150616462013-03-15T05:07:00.000-07:002013-03-15T05:07:02.845-07:00hello world in C#Most everyone starts with hello world in programmig. Even seasoned developers write hello world apps in order to test if the simplist solution will run.<br />
in c# we would write:<br />
public static class MyClass<br />
{<br />
public static void main()<br />
{<br />
System.IO.Console.WriteLine("Hello World");<br />
}<br />
}Kenneth Parkerhttp://www.blogger.com/profile/13907305526364974493noreply@blogger.com1