tag:blogger.com,1999:blog-75464379428651445652016-11-30T08:21:18.141-06:00The Business of IT: Theory, Practice and HumorBy Eric WeimerEric Weimernoreply@blogger.comBlogger24125tag:blogger.com,1999:blog-7546437942865144565.post-42699909752151539842013-09-03T15:39:00.000-05:002014-11-13T22:34:17.874-06:00Evidence-based Application Development Optimization<h2>Speeding up application development for the chief executive</h2>Running an IT&nbsp;organization&nbsp;is a complex task.<br /><br />Every CIO/CTO appreciates this, but is restricted by the limitations of their corporate culture. Influencers who have acquired a dangerous "little bit of knowledge" can represent significant obstacles.<br /><br />Among a chief executives primary tasks is overseeing application development. Research shows us that the rate of development has been constant for decades. Developers are, in fact, delivering more than ever. However this is offset by the fact that software development is many times more complex than it ever was. <br /><br />The best practices and concerns for the modern day Web Application dwarf what had to be accomplished in the original "green screen" applications of the 70's and 80's.<br /><br />There are many way to tweak productivity: industry best practices, for instance, are rarely achieved much more than 50%. Agile has been helpful, Scrum for project management and extreme programming for engineering practices. There is a multiple year learning curve, which is best streamlined by temporary consultants with good experience. But even Agile has been shown to account for a smaller than expected productivity gain.<br /><br />According to research (which has been around for years) there is but one thing that can be done to markedly improve productivity. A small number of companies are doing, and seeing real results.<br /><br />Here is a practical, evidence-based guide:<br /><h3>Building a quality staff</h3><ol><li><b>Invest in interview training</b>. The quality of IT interviews is poor, at best. Think about this: The majority of Americans think they are better than average drivers. This is a well known fact. I've seen no studies but personal experience is the majority of IT interviewers think they are very good. In fact, they are not. See my blog on interviewing architects for some examples.<br /></li><li><b>Favor quality over specific experience.</b> Although known for decades, IT job opportunities tend to stress how much exact experience candidates have, over the candidates abilities.</li><li><b>Be cognizant of the 10x rule. </b>Studies going back years show a considerable productivity gap among developers. Tailor your interview process to go after the highly productive developers.<br /></li><li><b>Compensate for the 10x-ers. </b>CFO's hate this. However would you rather hire 30 1-2x developers, or ten 9-10x developers? The math is trivial.<br /></li><li><b>Create strong management. </b>Many 10x-ers are quite opinionated, They'll need to be taught to work in an environment of peers, since during most of their experience, they have played the hero. Eliminate any that cannot get along with others, if they cannot be salvaged. It's all about establishing a culture of mutual respect.</li><li><b>Strategize to eliminate obstacles. </b>Paying 10%-20% more per developer is easily justified by showing you can get by with far fewer. This saves the company money. Each individual has a $30k or so benefit package, so spending more on fewer is just simple math. Other objections, like you need low level folks to do the grunge work, don't add up. Find all the objections, and create reasonable arguments to get by them. Memorize and repeat.<br /></li><li><b>Plan to turnover the staff. </b>Like most organizations, you likely have a mix of 1x-10x developers. Some of the 1x hold valuable business knowledge, so plan a gradual turn over to move to a staff made up of 8x-10x.</li><li><b>Measure productivity</b>. There are lightweight ways to get a reasonable approximation of productivity. Make them standard and start measuring, so you know who to keep.<br /></li><li><b>Listen to the staff. </b>Let IT decisions be made by the staff, who have the expertise. Certainly some high level decisions will continue to be made at the executive level, but measure each one, get feedback from the staff. and teach them to provide constructive criticism rather than make noisy complaints.</li></ol>The bottom line is due to the large range of developer productivity, reducing delivery time, reducing defects, and becoming good partners with department heads is most cost effectively achieved one way, according to the evidence.<br /><br /><h3>A Case History</h3>My first manager, on my first day of work, gave me an assignment to complete. Assuming slowness would be expected, I decided to take my time and quadruple check my work.<br /><br />I turned it in, and it was perfect. Except for one thing: I turned it in after 4 hours, and it was supposed to take 2 weeks.<br /><br />Years later a new manager replaced my first manager. This gentleman was what you might refer to as "slick". He started in a straightforward manner, but it did not take long before he began breaking rules for appearance sake.<br /><br />He was my first "politician" and I learned a lot from him. I also lost a lot due to him.<br /><br />I estimated a project for him using the new technology of the day. He apparently didn't like me, in fact you could say he hated me. But I assumed my performance would save me.<br /><br />He took away my staff and my project management role, then began development. I was eager to learn the new technology so I played along. Meanwhile he brought two developers with prior experience.<br /><br />Then he began a monthly ritual where I was called into his office and berated with the same questions each time: what's the problem, why are you behind schedule, why are you over budget, and why is the quality of your work so poor?<br /><br />My answers were all "I don't know."<br /><br />Hew really had me going. After several of these, I began to wonder why I was doing so poorly, so I analyzed the project and printed the results. I returned to my desk just as I was summoned to his office.<br /><br />It went like this:<br /><br /><span style="color: red;">VP: "What's the problem, Eric?"</span><br />Me: "I'm not aware of any problems."<br /><br /><span style="color: red;">VP: "Why are you behind schedule?"</span><br />Me: "I've been wondering that myself, so I added up the actuals versus estimates and found that while I've been over on some tasks, I've been under on others. Up to now, I'm actually ahead of schedule. In fact I'm the only team member who is ahead of schedule."<br />(I looked at his face actually hoping to see him smile. Instead, his face turned a pinkish hue.)<br /><br /><span style="color: red;">VP: "Why are you over budget?"</span><br />Me: "I've also been wondering about that, so I added up the actuals versus estimates and found that while I've been over on some tasks, I've been under on others. Up to now, I'm actually under budget. In fact I'm the only team member who is under budget."<br />(I looked at his face again wondering if he'd finally smile. Instead, his face had turned bright red.)<br /><br /><span style="color: red;">VP: "Why is the quality of your work so poor?"</span><br />Me: "That's more difficult to quantify. As you know the rule on this project is when someone produces a bug, someone else must fix it. According to the bug tracker, I've contributed fewer bugs than anyone on the team. I've also fixed more than anyone on the team. In fact, I've fixed more bugs than the rest of the team combined."<br />(His face had become an even darker shade of red, and he angrily claimed I had a bad attitude and through me out of his office. That was the last of those meetings.)<br /><br />Thus I saw the writing on the wall. Even though all the numbers pointed to me having the best performance of the team, my boss was not going to be happy, so I left my first company, giving up a sizable chunk of my ESOP, which eventually would have turned into 2-3 millions of dollars. <br /><br />Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-61581414927683235702013-09-03T14:15:00.000-05:002013-09-03T16:06:11.117-05:00How Much Money Do Consultants Really Make?<h2>How much do consultants really make?</h2>There are two ways to be a consultant: become an employee of a consulting firm, or go independant.<br /><br />Compensation varies with risk. Being an employee is less risky, so you can expect to be paid around 10% more for most technical roles, depending on demand, skill set, market pricing, etc.<br /><br />Independent consulting takes on the most risk, so you get paid more.&nbsp; But how do you understand exactly how much you're really being paid? <br /><br />A common approach is to take an hourly rate and apply a simple formula to convert it to the equivalent rate.<br /><br />Here is the basic US rate conversion. Note that certain individuals will have variations (especially when they are trying to sell you something!)<br /><br />The bottom line: The rate you get is not as much money as you think. Plus, you have to expect down time between gigs. <br /><h3>Step 1. Determine how many weeks of vacation you'd get for a perm job</h3>If you are young enough, two weeks is standard. However once you've been at 3 weeks or more, if you went for a perm job, you'd ask for at least 3 weeks.<br /><br />In my experience, some companies will try to pressure you to go back to two weeks. I've never failed to get 3 weeks. Just tell them you are used to 3 weeks, and they will (eventually) agree. Any more than 3 is rare for technical workers. It's more common when looking at executive management jobs.<br /><br /><h3>Step 2. Determine how much paid time off you'd get for a perm job</h3>Most companies offer 10 holiday/PTO days and 5 sick days, which is 15 days in total.<br /><br /><h3>Step 3. Calculate the number of paid days</h3>A year is 2080 hours.<br /><br />If you are at 3 weeks of vacation, use 15 vacation + 15 paid days off, or 30.<br />30 * 8 = 240<br />Subtracting 240 from 2080 = <b>1840</b>.<br /><br />For two weeks of vacation, use <b>1880</b>.<br /><h3>Step 4. Subtract missing benefits and overhead</h3>Most people agree you should subtract <b>$30,000</b> for missing benefits and overhead (lawyer, accountant, insurance, disability, etc.)<br /><br /><h3>Step 5. Do the Calculation</h3>Assuming three week vacation, it's 1840 * rate - $30,000. Or,<br /><table border="1"><tbody><tr> <th>Rate</th> <th>Salary</th> </tr><tr><td>$50</td><td>$62,000</td></tr><tr><td>$55</td><td>$71,200</td></tr><tr><td>$60</td><td>$80,400</td></tr><tr><td>$65</td><td>$89,600</td></tr><tr><td>$70</td><td>$98,800</td></tr><tr><td>$75</td><td>$108,000</td></tr><tr><td>$80</td><td>$117,200</td></tr><tr><td>$85</td><td>$126,400</td></tr><tr><td>$90</td><td>$135,600</td></tr><tr><td>$95</td><td>$144,800</td></tr><tr><td>$100</td><td>$154,000</td></tr></tbody></table><h3>How Much Should I Charge?</h3>Normal market rules apply. For example, the higher the rate, the less competitive you are. If you tops in your field, and can convince clients of that, then go for higher rates. <br /><br /><br />I talk to recruiters and find the rate ranges for specific jobs. Normally I find a minimum rate that provides plenty of work. Depending on the client, you can ask for that rate, or bump it up, etc.<br /><br /><br />Some rates are available in job ads, but not very many. Glassdoor.com is a good source. Between recruiters, ads and Glassdoor, you should be able to get a handle on how much you should be making.<br /><br /><br /><br />Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-68150477569257014222013-08-14T07:11:00.000-05:002013-08-28T11:30:48.592-05:00Java Architect Advanced Interview Questions and Answers **Updated for Java 7!**<h2>Advanced Java Interview Questions</h2>Having spent many years as both a consultant <i>and </i>Java Web Architect, I've had my fair share of interviews. Some have been excellent, but most, well, not so much.<br /><br />Obviously you need someone as technical as an architect to tech an architect. If you don't have a good architect available, rent one. I've interviewed for companies myself, and I enjoy doing it.<br /><h2>Interview Anti-Patterns</h2>Before we got on with the questions, here are some things that interviewers should avoid:<br /><ol><li><span style="color: #cc0000;"><b>Seek similar opinions</b>. There are well established best practices in IT, yet some interviewers cannot help themselves seek agreement in the gray areas. A variety of opinion is a good thing!</span></li><li><span style="color: #cc0000;"><b>API questions.</b> Memorizing API's is a great way to get a job your not qualified for. The rule of thumb is any detailed knowledge that is quickly discoverable does not belong in an interview.</span></li><li><span style="color: #cc0000;"><b>Irrelevant questions.</b> A very sharp consultant I knew insisted in including questions about EJB 2, even though the client did not use the technology. This was because he was once burned by a developer who didn't understand how EJB worked, which leads us to the next item:</span></li><li><span style="color: #cc0000;"><b>Substitution. </b>Learn from past failures, but don't substitute questions. If your using Spring, ask questions about Spring, not EJB.</span></li><li><span style="color: #cc0000;"><b>Dependent Sets</b>. If the interviewee does not know what a dynamic proxy is, don't follow that question up with more specifics regarding dynamic proxies.&nbsp;</span></li><li><span style="color: #cc0000;"><b>Obsolescence. </b>I still get questions like "what are two ways to create a thread". This has been obsolete since Java 5.</span></li><li><span style="color: #cc0000;"><b>Suitability. </b>When interviewing for an architect role, I was actually asked what is the difference between a class and an object. The interviewer apologized, saying it was a company rule.</span></li></ol><h2>Common Failures </h2><ol><li><span style="color: #cc0000;"><b>Qualifications.</b> Does your organization train it's IT employees how to interview? The cost is trivial, yet few organizations do so. Yet they insist it's their people who make them excellent.</span></li><li><span style="color: #cc0000;"><b>Reality Check.</b> The majority of Americans believe they are <i>better than average</i> drivers. My personal observation is most IT interviewers believe they are <i>uniquely good</i> interviewers.</span></li></ol><h2></h2><h2>Interview Best Practices</h2><ol><li><span style="color: #cc0000;">Do not allow anyone to interview <b>until they have been briefed by HR</b> on legal restrictions and corporate policies. For instance, you cannot ask about age, health, marital status, etc.&nbsp;</span></li><li><span style="color: #cc0000;">Do not allow anyone to interview <b>without training</b>. Recruiting is a key component of business success.</span></li><li><span style="color: #cc0000;">Ask questions that <b>test understanding</b>, rather than listing items. For instance, instead of asking what data structures does Java provide, ask what are the differences between sets and lists.</span></li><li><span style="color: #cc0000;">Ask questions that <b>aren't easily memorized</b>. One company I worked with requested a short, four, program be written. Half the people who passed the first technical screen could not write a simple program!</span></li><li><span style="color: #cc0000;">Before the interview, ask the candidate to write a simple program. </span></li><ol><li><span style="color: #cc0000;">Ensure all requirements are complete and clear.&nbsp;&nbsp; </span><span style="color: #cc0000;"><br /></span></li><li><span style="color: #cc0000;">If you want tests, ask for them.&nbsp;</span><span style="color: #cc0000;"></span></li><li><span style="color: #cc0000;">Keep the program simple so that it can be done with 2-4 hours.</span></li><li><span style="color: #cc0000;">Omit the GUI to keep it short.</span></li><li><span style="color: #cc0000;">Explain how you want it packaged and delivered</span></li><li><span style="color: #cc0000;">Provide a precise delivery date and give them a few days to complete it</span></li><li><span style="color: #cc0000;">Explain how the program will be scored.&nbsp; </span><span style="color: #cc0000;"><br /></span></li></ol><li><span style="color: #cc0000;">Ask each candidate for the same role the same questions, and score the results. The numbers will support your decision. Of course you also need to evaluate cultural fit and other factors.</span></li><li><span style="color: #cc0000;">Clearly define roles. I've performed technical evaluations while a manager evaluates candidates for attitude, etc. That makes the technical screen easier.</span></li><li><span style="color: #cc0000;">Follow up. I once interviewed a brilliant candidate who was poorly suited for consulting. The recruiter hired him despite my recommendations, and the candidate was done in a matter of months.</span></li><li><span style="color: #cc0000;">Cover the technologies needed for the job.&nbsp;</span></li><li><span style="color: #cc0000;">Favor capable candidates over those who have more experience with the technologies necessary for the job. Good people will pick up what they need to know.</span></li><li><span style="color: #cc0000;">In addition to specific technologies, include general questions. For instance, if an object orientated language is being used, ask some general OO questions.</span></li><li><span style="color: #cc0000;">Ask questions about the field in general. Candidates who know nothing but the technologies they've been asked to use in the past are less likely to excel than candidates who know about their field in general.</span></li></ol><h2>Case Study</h2>At a client I interviewed candidates with two team leads. To prepare, I simply threw together a spreadsheet with around 5 questions for each job requirement (it's all we had time to ask).<br /><br />The questions ranged from simple to very advanced. Each questioned had a 'value' assigned, the simple questions having the highest, the advanced the lowest. I added simple formulas to sum results and copied the original tab for each interview.<br /><br />We ended with a short list of two candidates, who seemed to be roughly equal. However I preferred the woman and my two male team leads preferred the man.<br /><br />To resolve the impasse, I opened the spreadsheet and compared results. Within a minute we realized the woman answered one more question in each and every category! So we agreed to hire her, and she performed well.<br /><br />The morale of the story is, with a trivial amount of extra effort, we made a better choice, because we used objective measures.<br /><br />I always recommend you tech your prospective architect. In fact I've been paid to tech Java architects and developers as a part time job.<br /><br />Think about it, someone decided to pay ME to interview their Java candidates.Wonders never cease.<br /><h2>Interview Questions</h2>Here are some questions any good architect should know. Pains have been taken to avoid ambiguous answers, but YMMV. <br /><h3>Select the BEST answer...</h3><h4>Simple Questions (15 points each)</h4>1. xUnit is a family of frameworks that can be used for:<br />&nbsp; &nbsp; a. Unit tests <br />&nbsp; &nbsp; b. Integration tests <br />&nbsp; &nbsp; c. Both unit and integration tests<br />&nbsp; &nbsp; d. xUnit has nothing to do with testing<br /><br />2. TDD stands for:<br />&nbsp; &nbsp; &nbsp;a. Temporal Date Design patterns <br />&nbsp; &nbsp; &nbsp;b. Test Driven Development<br />&nbsp; &nbsp; &nbsp;c. Test Driven Design<br />&nbsp; &nbsp; &nbsp;d. Both b and c<br /><br />3. One object&nbsp;oriented&nbsp;design technique is:<br />&nbsp; &nbsp; &nbsp;a. Noun Harvesting<br />&nbsp; &nbsp; &nbsp;b. Design Patterns<br />&nbsp; &nbsp; &nbsp;c. UML<br />&nbsp; &nbsp; &nbsp;d. BREAD<br /><br />4. A UML Class Diagram does not&nbsp;sufficiently&nbsp;describe an OO system because:<br />&nbsp; &nbsp; &nbsp;a. It does not show interfaces<br />&nbsp; &nbsp; &nbsp;b. It does not show composition<br />&nbsp; &nbsp; &nbsp;c. It does not show class relationships<br />&nbsp; &nbsp; &nbsp;d. It is a static diagram<br /><br />5. The difference between aggregation and composition is:<br />&nbsp; &nbsp; &nbsp;a. They are both the same<br />&nbsp; &nbsp; &nbsp;b. Composition is an "owning" relationship<br />&nbsp; &nbsp; &nbsp;c. Aggregation is an "owning" relationship<br />&nbsp; &nbsp; &nbsp;d. Composition groups like objects, aggregation groups family's of objects<br /><h4>Medium Difficulty (10 points each)</h4>6. A domain model is:<br />&nbsp; &nbsp; a. The entire application<br />&nbsp; &nbsp; b. An object oriented model that represents user interactions<br />&nbsp; &nbsp; c. An object&nbsp;oriented&nbsp;model of the business that the application is automating<br />&nbsp; &nbsp; d.&nbsp;An object oriented model&nbsp;containing the business rules<br /><br />7. The difference between "rich" and "anemic" domain models is:<br />&nbsp; &nbsp; &nbsp;a. A rich model has business logic<br />&nbsp; &nbsp; &nbsp;b. A rich model has Design Patterns<br />&nbsp; &nbsp; &nbsp;c. An anemic model has no Design Patterns<br />&nbsp; &nbsp; &nbsp;d. Both b and c<br /><br />8. Refactoring is:<br />&nbsp; &nbsp; &nbsp;a. A process to fix bugs introduced by programmers<br />&nbsp; &nbsp; &nbsp;b. Any general bug fix<br />&nbsp; &nbsp; &nbsp;c. A re-architecture of the code that does not change it's behavior<br />&nbsp; &nbsp; &nbsp;d.&nbsp;A re-architecture of the code&nbsp;to make it more efficient<br /><br />9. Scrum is:<br />&nbsp; &nbsp; &nbsp;a. An Agile methodology<br />&nbsp; &nbsp; &nbsp;b. All you need to be "Agile"<br />&nbsp; &nbsp; &nbsp;c. Assumes developers use best development practices<br />&nbsp; &nbsp; &nbsp;d. a and c<br /><br />10. Which of the following is NOT a common architectural application tier:<br />&nbsp; &nbsp; &nbsp;a. Presentation tier<br />&nbsp; &nbsp; &nbsp;b. Persistence tier<br />&nbsp; &nbsp; &nbsp;c. Object Orientated tier<br />&nbsp; &nbsp; &nbsp;d. Both a and b<br /><h4>Advanced Questions (5 points each)</h4>11. The expression "favor composition over inheritance":<br />&nbsp; &nbsp; &nbsp;a. Is stated in the "Gang of Four" <i>Design Patterns</i> book<br />&nbsp; &nbsp; &nbsp;b. Appeared after the "Gang of Four" <i>Design Patterns</i> book<br />&nbsp; &nbsp;&nbsp; c. Is based on the idea that inheritance is more tightly coupled than composition.&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; d. Is based on the idea that composition is more tightly coupled than inheritance.<br />&nbsp; &nbsp;&nbsp; e. Both A and D<br />&nbsp; &nbsp;&nbsp; f. Both A and C<br /><br />12. The&nbsp;Liskov substitution principle:<br />&nbsp; &nbsp; &nbsp;a. Is required to support class inheritance <br />&nbsp; &nbsp; &nbsp;b. Is a mathematical model for the facade Design Pattern<br />&nbsp; &nbsp; &nbsp;c. Is a mathematical principle that has nothing to so with programming<br />&nbsp; &nbsp; &nbsp;d. Makes all computer languages work<br /><br />13. GRASP is:<br />&nbsp; &nbsp; &nbsp;a. An acronym for a set of practices that lead to good UI design<br />&nbsp; &nbsp; &nbsp;b. Is Craig Larman's&nbsp;learning aid to help in the design of object-oriented software<br />&nbsp; &nbsp; &nbsp;c. Is Peter Coad's learning aid to help in the design of User Interfaces<br />&nbsp; &nbsp; &nbsp;d. A trick question, there is no reference to GRASP in computer literature<br /><br />14. Design Patterns are:<br />&nbsp; &nbsp; &nbsp;a. Common object orientated solutions<br />&nbsp; &nbsp; &nbsp;b. New objected&nbsp;oriented&nbsp;solutions<br />&nbsp; &nbsp; &nbsp;c. Created by Java experts to teach good design<br />&nbsp; &nbsp; &nbsp;d. Only useful to architects<br /><br />15. Agile methods are:<br />&nbsp; &nbsp; &nbsp;a. An example of "Waterfall" methodologies<br />&nbsp; &nbsp; &nbsp;b. A fad no longer recommended by industry leaders<br />&nbsp; &nbsp; &nbsp;c. No different than development techniques of the last 30 years<br />&nbsp; &nbsp; &nbsp;d. Considered a current industry best practice<br /><h4>Java version 5-7 questions (5 points each)</h4>16. Java 5 Generics:<br />&nbsp; &nbsp; &nbsp;a. Ensure compile-time type safety<br />&nbsp; &nbsp; &nbsp;b. Ensure compile and runtime type safety<br />&nbsp; &nbsp; &nbsp;c. Have nothing to do with type safety<br />&nbsp; &nbsp; &nbsp;d. Are useful only for Java collections <br /><br />17. What is the most significant cause of concern for Java Annotations?<br />&nbsp; &nbsp; &nbsp;a. You cannot create your own annotations<br />&nbsp; &nbsp; &nbsp;b. They cause additional classes to be loaded, slowing performance<br />&nbsp; &nbsp; &nbsp;c. The represent a tight coupling<br />&nbsp; &nbsp; &nbsp;d. There are no significant drawbacks<br /><br />18. Regarding CMP and JPA:<br />&nbsp; &nbsp; &nbsp;a. JPA and CMP are designed to work together, but CMP is optional<br />&nbsp; &nbsp; &nbsp;b. JPA and CMP are designed to work together, and CMP is required<br />&nbsp; &nbsp; &nbsp;c. JPA without CMP requires a JTA transaction controller<br />&nbsp; &nbsp;&nbsp; d. JPA replaces CMP<br /><br />19. Advantages of the Spring Framework over JPA:<br />&nbsp; &nbsp; &nbsp;a. JPA is a standard<br />&nbsp; &nbsp; &nbsp;b. Spring supports Dependency Injection<br />&nbsp; &nbsp; &nbsp;c. JPA uses annotations that couple domain classes to the framework<br />&nbsp; &nbsp; &nbsp;d. Spring is free<br /><br />20. Advantages of JPA over the Spring Framework:<br />&nbsp; &nbsp; &nbsp;a. None. The advantages are part of CMP<br />&nbsp; &nbsp; &nbsp;b. JPA is implemented by Hibernate "under the covers"<br />&nbsp; &nbsp; &nbsp;c. JPA provides vendor independence<br />&nbsp; &nbsp; &nbsp;d. Spring uses more libraries<br /><br /><h4>New Technology</h4>21. What is the biggest difference between Ruby and Groovy?<br />&nbsp; &nbsp; &nbsp;a. Groovy uses the familiar C-based syntax while Ruby does not<br />&nbsp; &nbsp; &nbsp;b. Ruby supports runtime code compilation.<br />&nbsp; &nbsp; &nbsp;c. Groovy is meant for scripting<br />&nbsp; &nbsp; &nbsp;d. Ruby executes faster because it's written in C.<br /><br />22 Grails is considered scalable:<br />&nbsp; &nbsp; &nbsp;a. Because it supports static classes<br />&nbsp; &nbsp; &nbsp;b. Because it supports multithreading while Rails does not<br />&nbsp; &nbsp; &nbsp;c. Because it is based on Spring and Hibernate<br />&nbsp; &nbsp; &nbsp;d. Grails has not been shown to scale.<br /><br />23 Which is easier to learn: Grails or Rails?<br />&nbsp; &nbsp; &nbsp;a. Rails, because Ruby has a simpler syntax.<br />&nbsp; &nbsp; &nbsp;b. Rails, because it uses more common Design Patterns<br />&nbsp; &nbsp; &nbsp;c. For Java developers, Rails, because Ruby is simpler than Java.<br />&nbsp; &nbsp; &nbsp;d. For Java developers, Grails, because Groovy is mostly Java compatible.<br /><br />24 NoSql database performance can be restricted by:<br />&nbsp; &nbsp; &nbsp;a. Access via services, which are slower than direct calls .<br />&nbsp; &nbsp; &nbsp;b. The CAP theorum<br />&nbsp; &nbsp; &nbsp;c. The DAP theorum<br />&nbsp; &nbsp; &nbsp;d. Both c and d.<br /><br />25 Cloud computing:<br />&nbsp; &nbsp; &nbsp;a. is always hosted by a third party like Amazon, Google or Rackspace<br />&nbsp; &nbsp; &nbsp;b. requires NoSQL databases<br />&nbsp; &nbsp; &nbsp;c. cannot be used to host Java Web Applications<br />&nbsp; &nbsp; &nbsp;d. achieves economy of scale<br /><br /><br /><br />-<br />-<br />- <br />F<br />I<br />L<br />L<br />E<br />R<br />-<br />-<br />-<br />A<br />N<br />S<br />W<br />E<br />R<br />S<br /><br />B<br />E<br />L<br />O<br />W<br />-<br />-<br />-<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><h2>Answers:</h2><ol><li>xUnit is a family of frameworks that can be used for:</li><ul><li>Answer:c. Both unit and integration tests</li><li>Note:jUnit, like other xUnit variations, can drive both unit and integration tests, as well as others.</li></ul><li>TDD stands for:</li><ul><li>Answer: d: Both b and c</li><li>Note:TDD is alternatively called Test Driven Design or Test Driven Development</li></ul><li>One object&nbsp;oriented&nbsp;design technique is:</li><ul><li>Answer: a. Noun Harvesting</li><li>Note:Noun harvesting is a classic OOD technique</li><li>Note:None of the others are OOD techniques</li></ul><li>A UML Class Diagram does not&nbsp;sufficiently&nbsp;describe an OO system because:</li><ul><li>Answer:d. It is a static diagram</li><li>Note:Class diagrams do not document object interactions</li><li>Note:Other diagrams like sequence and activity diagrams capture dynamic interactions</li></ul><li>The difference between aggregation and composition is:</li><ul><li>Answer: Composition is an "owning" relationship</li><li>Note:In composition, if an object is removed, it's related objects are also removed</li><li>Note:In aggregations, related objects can exist on their own</li></ul><li>A domain model is:</li><ul><li>Answer: c. An object&nbsp;oriented&nbsp;model of the business that the application is automating</li><li>Note:The term "domain" refers to the business domain being automated by the application</li></ul><li>The difference between "rich" and "anemic" domain models is:</li><ul><li>Answer: a. A rich model has business logic</li><li>Note: According to Martin Fowler, a rich model contains business logic</li><li>Note: According to Martin Fowler, an anemic model contains POJO)'s (properties, getters, setters, equals() and HashCode()).</li></ul><li>Refactoring is:</li><ul><li>Answer: c. A re-architecture of the code that does not change it's behavior</li><li>Note: Martin Fowler wrote the refactoring "bible".</li></ul><li>Scrum is:</li><ul><li>Answer: d. a and c</li><li>Note: Scrum is considered an Agile Methodology</li><li>Note: Scrum assumes developers use best development practices, like Extreme Programming</li><li>Note: A project with Scrum and traditional engineering practices is not considered "Agile".</li></ul><li>Which of the following is NOT a common architectural application tier:</li><ul><li>Answer:&nbsp; c. Object Orientated tier</li><li>Note: Presentation and Persistence are common architectural tiers managing the User Interface and data persistence respectively. The "middle" tier has various names, or is sometimes just called the "middle tier".</li></ul><li>The expression "favor composition over inheritance":</li><ul><li>Answer:&nbsp; f. Both A and C</li><li>Note: This advice appeared as early as the 1995 GOF <i>Design Patterns</i> book </li><li>Note: We favor composition because it is more loosely coupled than inheritance</li></ul><li>The&nbsp;Liskov substitution principle:</li><ul><li>Answer: a. Is required to support class inheritance </li><li>Note: The&nbsp;Liskov substitution principle defines how sub-types work.</li><li>Note:It applies only to OO languages.</li></ul><li>GRASP is:</li><ul><li>Answer:b. Is Craig Larman's learning aid to help in the design of object-oriented software</li><li>Note: Craig Larman wrote the classic book <i>Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process</i></li></ul><li>Design Patterns are:</li><ul><li>Answer: a. Common object orientated solutions</li><li>Note: Curiously the Java folks created a number of "patterns" intended to be used in web applications, which contradicts the definitions of "well known".</li><li>Note: Most Java architects tried, then abandoned, most of the Java patterns, especially after Martin Fowler's classic <i>PofEAA</i> book was published.</li></ul><li>Agile methods are:</li><ul><li>Answer: d. Considered a current industry best practice</li><li>Note:The debate has ended some time ago.</li></ul><li>Java 5 Generics:</li><ul><li>Answer:&nbsp; a. Ensure compile-time type safety</li><li>Note: Generics are a compile-time only feature</li><ul></ul><li>Note: IMHO, after a decade of code reviews, I have yet to see a bug that generics would have prevented.&nbsp;</li><li>Note: Generics make Java code even more verbose (<a href="http://groovy.codehaus.org/" target="_blank">see Groovy</a>) </li><li>Note: Most IT shops I know have added generics as a coding requirement</li></ul><li>What is the most significant cause of concern for Java Annotations?</li><ul><li>Answer: C: The represent a tight coupling</li><li>Note: (A) is not true</li><li>Note: The overhead referred to in (B) is trivial. </li><li>Note: Annotations represent a tight coupling to a specific framework.&nbsp; </li><li>Note: Tight coupling has historically been considered a significant negative. However many Java folks are embracing annotations for code reduction. This trade-off is still being debated. However it can be confidently stated that the tight coupling annotations represent is their major concern.</li></ul><li>Regarding CMP and JPA:</li><ul><li>Answer: d. JPA replaces CMP</li></ul><li>Advantages of the Spring Framework over JPA:</li><ul><li>Answer: c. JPA uses annotations that couple domain classes to the framework</li><li>(A) is commonly used to cite advantage for JPA, not Spring.</li><li>(B) Both solutions support DI.</li><li>(D) Both solutions can be obtained free of charge. </li><li>Note: Java annotations, like any direct class reference, represents a tight coupling.</li><li>Note: Tight coupling makes changing the dependent framework more expensive.</li></ul><li>Advantages of JPA over the Spring Framework:</li><ul><li>Answer: c. JPA provides vendor independence</li><li>Note: (A) JPA deprecates CMP</li><li>Note: (B) This is irrevelant to the question. </li><li>Note: (D) The fact Spring uses more libraries is not considered an issue.</li></ul><li>What is the biggest difference between Ruby and Groovy?</li><ul><li>Answer: a. Groovy uses the familiar C-based syntax while Ruby does not</li><li>Note: Both languages tend to keep up with each others features</li><li>Note: Both Java and Groovy use "C" syntax, while Ruby does not</li></ul><li>Grails is considered scalable </li><ul><li>Answer: c. Because it is based on Spring and Hibernate</li><li>Note: Grails began as an API over Spring and Hibernate, both known to scale.</li><li>Note: At that time Rails did not support multi-threading and was restricted to small web applications.</li><li>Note: Rails scales quite well now.</li></ul><li>Which is easier to learn: Grails or Rails?</li><ul><li>Answer: d. For Java developers, Grails, because Groovy is mostly Java compatible.</li><li>Note: (A-C) are incorrect</li></ul><li>NoSql database performance can be restricted by:</li><ul><li>Answer: b. The CAP theorum</li></ul><li>Cloud computing:</li><ul><li>Answer: d. achieves economy of scale</li><li>Note:(A-C) are not true</li></ul></ol>If anyone has opinions or facts that are pertinent to this posting, I'd love to hear about them.<br /><br />Thanks, and have a pleasant tomorrow.<br /><br /><br />Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com2Lisle, IL 60532, USA41.794402 -88.08030509999997541.6996855 -88.241666599999974 41.889118499999995 -87.918943599999977tag:blogger.com,1999:blog-7546437942865144565.post-49112859245678096462012-11-29T02:28:00.001-06:002012-11-29T02:38:52.910-06:00Is Agile Disappointing?<div style="text-align: center;"><span style="font-size: large;"><br /></span></div><div style="text-align: center;"><span style="font-size: large;">Are you&nbsp;disappointed&nbsp;with your Agile&nbsp;rollout?</span></div><div style="text-align: center;"><span style="font-size: large;"><br /></span></div><div style="text-align: center;"><span style="font-size: large;">Not seeing the benefits the Agile zealots promised?</span></div><br />Don't pay attention to the Agile zealots!<br /><br />Smart execs leverage&nbsp;empirical&nbsp;evidence. Mediocre managers get sold. Don't be mediocre!<br /><br />So what is the&nbsp;empirical&nbsp;evidence? As it turns out, some organizations gain significant benefit from Agile. Some do not. Why?<br /><br /><i>Human nature</i>.&nbsp;People who lack confidence tend to resist change, while confident professionals thrive on change.<br /><b><br /></b> <b>Lip service Agile</b> is a term frequently associated with an IT group who&nbsp;attempts to create the appearance they have adopted Agile yet continues using legacy development practices.&nbsp;A common strategy is to pepper communications with word "Agile" hoping management will confuse that with actual Agile adoption. (I've seen this a number of times.)<br /><br />Fortunately there are good ways to understand whether your organization is really Agile. Here is a list of some of the most common symptoms:<br /><ol><li><b>Agile novice syndrome.</b>&nbsp; Agile can be quite appealing and the IT world is rife with stories of well meaning folks who've read about Agile and talk their boss into letting them try it. However Agile is&nbsp;very difficult to&nbsp;&nbsp;"get". If your staff is running an Agile project without an experienced coach, it is almost certainly going to fail to realize Agile benefits.</li><li><b>Half Agile.</b> When organizations adopt Scrum but retain legacy development practices. Scrum assumes the use of industry best development practices. The safest bet is to adopt Scrum <i>and </i>Extreme Programming.</li><li><b>Fragmented Agile. </b>Well meaning managers who do not personally agree with specific Agile practices pull the plug on critical activities. Fortunately identification is simple: quiz the team. They should be doing <b>all</b> of these activities:<br /><br /><div style="margin-left: 5%;">1. Pairing at least 6 hours per day<br />2. Writing unit tests first <br />3. Attending no more than one, daily, 10 minute stand-up meeting <br />4. Engages at least one full time product owner and acceptance tester <br />5. Estimates are expressed in story points, and <i>not </i>associated to an amount of time <br />6. Iterations are with 1 or 2 weeks long <br />7. Runs ALL the various Scrum meetings (retrospectives, iteration planning, etc.) <br />8. Does NOT have status meetings<br />9. Maintains a burndown chart <br />10. Calculates the velocity each iteration <br />11. No one assigns tasks to other people<br />12. Performance testing starts early in the project <br />13. Requirements are specified by user stories (that fit on an index card)<br />14. The continuous integration server runs all day at approximately 20 minute intervals <br />15. Delivers user observable results in every iteration for every story<br />16. All stories are small enough that they can be completed within an iteration <br />17. Stories are not done until the product owner agrees they are done <br />18. Detailed requirements are not captured until the associated story is scheduled to be worked on<br />19. Technical documentation (other than architecture) exists solely in executable tests <br />20. Failing tests receive top priority; 100% of tests generally pass <br />21. Test coverage is nearly 100% (some trivial code can be excluded) <br />22. Bug detectors (like FindBugs) are run as part of continuous integration <br />23. No more than the minimal amount of code needed to complete a story is written<br />24. Code is committed to a source code repository daily<br />25. Every member of the team takes ownership over the entire code base<br /><br /></div></li><li><b>Cowboy Developers. </b>Strong willed developers sometimes try to skip specific practices they personally don't agree with. For example, if your architect&nbsp;laments&nbsp;that not everyone is writing tests, you need to fix that. </li><li><b>Assertiveness&nbsp;Challenged Leaders. </b>Sometimes leaders decide it's easier to bend to a strong willed developer than enforce standards. You need to fix that ASAP.</li><li><b>Unsupported&nbsp;Agile Coaches. </b>Agile coaches must have the final say.&nbsp;</li><li><b>Insufficient&nbsp;Buy-In. </b>Upper management must be 100% behind the Agile effort.</li><li><b>IT Isolation. </b>Everyone in the organization associated with the project must agree to Agile processes. Agile is implemented by the entire organization.</li></ol><div></div><br />Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-36910459790244210662012-08-16T23:09:00.002-05:002012-08-16T23:09:14.183-05:00Dorm Room PrintersI was&nbsp;challenged&nbsp;recently to find a good printer for a college setting. For whatever reason there are few articles (and even fewer of acceptable quality) recommending printers for the college student.<br /><br />I did some research, which is what I often do in a professional capacity, so I imagine I might be relatively good at it. This article is current as of August, 2012.<br /><br />Initially I checked out some printers available at the local Best Buy. Unfortunately, I went a second time and found the sales people were telling me entirely different stories.<br /><br />One kind salesperson offered to pull up the reviews of an HP printer that had the features I needed. The top of the review showed an average score of 3 out of 5, and he said "see, those are good reviews." "Just 3 out of 5? No, they are not" I thought to myself.<br /><br />So I relegated myself to the prospect of doing some of my own research. I was hoping to complete this task quickly but I wanted the best bang for my buck.<br /><br /><b>Requirements&nbsp;</b><br />It makes the evaluation much easier if a few minutes are spent on requirements. The following are requirements for my case, but I think these apply to most college students.<br /><br /><b>Price</b><br />Price is entirely up to you, however with the high cost of college plus the fact that there are many excellent printers under $150, I&nbsp;examined&nbsp;only $150 or less, and my choice ended up costing $91 at Amazon.<br /><br /><b>Size</b><br />Dorm rooms and college apartments tend to be small, so a small footprint is highly desired.<br /><br /><b>Speed</b><br />For many years we had to depend on&nbsp;manufacturer&nbsp;speed ratings, which varied widely. Thankfully there is now an ISO standard, so use that when comparing print speeds.<br /><br />I always feel speed is important. In this price range, there is the Epson Stylus NX430, which prints at 6.2 pages per minute. The Canon Pixma MG5320 prints at 12.5, roughly twice as fast. The Canon gets better reviews as well. You may think speed is a nice to have, but waiting for a long term paper to churn out can be an aggravating experience.<br /><br /><b>Copy, Scan, Fax</b><br />Fax is least important for the student, and with scan, internet-based fax services can be an inexpensive alternative. I do find copy and scan both useful, and since they are common in sub-$150 printers, I see no reason to exclude them.<br /><br /><b>Duplex</b><br />I recommend to everyone that they buy only&nbsp;duplex&nbsp;printers (printers that print on both sides of the paper). This not only saves trees but money as well. Duplex is now very common and no longer adds a premium to the price.<br /><br /><b>Size</b><br />Obviously in a small dorm room or college apartment, the smaller the better. There are smaller printers than my pick, but just by a couple of inches.<br /><br /><b>Print Quality</b><br />Even at this price point we can expect excellent print quality and pretty good picture quality. Don't forget to equip your student with paper. I start with a ream (300) and provide more once they get low. I prefer 22 or 24 pound, 20 pound is just too flimsy. Remember they are&nbsp;competing&nbsp;for grades and every little detail may help.<br /><br /><b>Noise</b><br />Low noise is a nice to have, but low on my priority list.<br /><br /><b>Ink</b><br />Printers can be pretty inexpensive since&nbsp;manufacturers&nbsp;continue to make money on selling you replacement ink. I always equip my college students with an extra complete set of ink, and ask them to let me know as soon as they replace any. You always want a complete set on hand, especially for those late night reports.<br /><br />Ink prices vary a little between&nbsp;manufacturers. I did not check those out but you can search for articles that have done the evaluation. It was not a priority of mine. Note that ink is almost always more expensive for older printers, and my goal was to purchase a printer that would survive four years of college.<br /><br /><b>Maintenance Agreements</b><br />When spending this little on a printer, I just take the chance. If it breaks after the&nbsp;warranty&nbsp;period, it's only $100 to replace.<br /><br /><b>Brand</b><br />My personal assessment of user reviews for the current under $150 printers is, in order of best to worst, Canon, Epson, HP.<br /><br /><b>Results</b><br />I decided to purchase the Canon PIXMA MG5320 ($91 on Amazon). It has better reviews than the&nbsp;competitors&nbsp; met all my requirements, and although smaller printers are available, it is fairly compact.<br /><br />Print speed is good (12.5 black, 9.3 color). It has a number of additional features, the only one missing is the ability to print through wifi without a router.<br /><br /><b>No Wifi Network?</b><br />HP has the feature that allows printing wirelessly without a wifi network. Unfortunately the folks at Best Buy could not consistently tell me which printers had that feature, and they claimed that no other brand offered it, and I am not sure this is true.<br /><br />In my situation, the college does not provide, nor allow, dorm students to have wifi in their rooms. This rule will probably have to go away in the near future, so for now students will have to plug the printer into their laptop via USB, which is not a big deal. So be sure to buy a 6 - 10 foot USB 2 cable as well.<br /><br />Reviews of other Canon MGxxxx printers did as well except for one model, so if you want to explore alternatives, check out user reviews. (User reviews often differ from professional reviewers, and tend to be more useful.)<br /><br />Just remember to&nbsp;separate&nbsp;out the negative reviews due to the seller, equipment broken in shipment, etc. Also remember that if ten people say xxx was no problem for every one who complained about xxx, then xxx is probably OK, unless all the complainers had the same laptop you own, and so forth.<br /><br /><b>Laptops</b><br />If your goal is to buy one laptop that will last a student four years, do not but a $500 laptop! What you get with more money are better and faster parts, which translates to a longer period of use. A $500 laptop will need to be replaced in 2, maybe 3 years. Luckily prices have gone down, and I purchased a nice, thin performant Dell laptop for my wife that should make it to four years for less than $1600. It was not too long ago that I'd never consider a sub-$2000 laptop.<br /><br />Critical factors for a laptop are memory, disk space and CPU. I would start with 8 GB of memory, making sure you can install at least 16GB down the road. The ideal hard drive would be between 500GB and 1TB at 7200 rpm. (Note that some brands only offer 5400 rpm hard drives, so if you get one of those you can replace it with an SSD later on.)<br /><br />Always avoid the top of the line CPU, but get one two or three speeds from the top. Today that would be a quad core Intel or AMD.<br /><br />Screen size is a personal preference. I prefer 17" non-glare but had to buy a glossy since that's all they had. Glossy screens have been a fad and most users find they prefer non-glossy, non-glare screens. People in their 20's or 30's can get by with smaller screens, but I'd go no less than 15". Plan to add a 22" flat panel if they use the computer more than a few hours per day.<br /><br />Finally, plan to buy a 1 or 2 TB external drive (preferably&nbsp;USB 3) for backup.<br /><br /><br />Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-76305833688535038042012-03-20T12:20:00.000-05:002013-09-03T16:05:19.539-05:00The Death of Java - Generics and AnnotationsJava has been dying a slow death for some years now. Competition from higher productivity languages has forced Java to market "Java as a platform", rather than Java as a language. Businesses can take advantage of the benefits of the JVM while having the freedom to choose from a variety of programming languages.<br /><br />Yet, Java persists, and for many reasons. It is difficult to change, for one thing. And what is the next platform? There are no clear choices. A few years ago Grails and Rails seemed positioned to take over, but their growth has begun to decline. Lighter weight platforms that claim to support larger numbers of threads are becoming popular. But critics argue they don't achieve expected performance, and are missing common useful features provided by Jee.<br /><br />Two troublesome directions that have become popular in Java are Generics and Annotations.<br /><br />The classic challenge of any software is to add new features and paradigms while maintaining compatibility with existing solutions. Over time this challenge results in either the death of the software or a new release that forces users to "freeze" their upgrades until they complete a "conversion".<br /><br />Neither of these options are appreciated by users.<br /><br /><br />Generics are a good example of how Java is dying. What seemed like a good idea has, in my opinion, backfired. To understand this, we need to understand how we got here.<br /><br /><b>Type-safety</b> <br />Many years ago IBM introduced a programming language designed to replace all others with a single language, and called it PL-1 (Programming Language One). PL-1 was designed to be powerful, yet it failed for a simple reason: it was very easy to code bugs.<br /><br />Languages evolved to improve this situation, and one of the most successful features was <i>type safety. </i>Simply put, type safety meant variables could be declared as having a type (string, integer, etc.) and the compiler would produce errors if the programmer tried to use that variable as a different type. <i>Strongly typed languages </i>forced programmers to specify the type of all variables.<br /><br />Interestingly, bugs were reduced by restricting what a programmer could do.<br /><br /><b>Java's type safety</b><br />The term <i>strongly typed</i> became muddled over the years, and zealous programmers engaged in lengthy debates arguing over semantics. Java is, by design, strongly typed. However it is also Object Orientated, using the classic "everything descends from a single object" paradigm. So there is nothing preventing programmers from declaring variables to be of type Object, which neatly defeats type safety.<br /><br /><b>Collections</b><br />Java 3 provided the Collections framework, an implementations of common data structures (lists, sets, maps and bags). Designed for maximum usability, collections store references to many types by declaring much of it's api to be a high level type, even of type Object. <br /><br /><b>What was the problem with Collections?</b><br />Collections were not type-safe. Let's say a developer creates a collection of strings. Later on she (or someone else) starts storing numbers in the same collection. This usually results in bugs since the existing code assumes that the collection contains strings.<br /><br /><b>Generics come to the rescue!</b><br />With the release of Java 5, the generics feature fixed this hole for collections (and in general). Programmers could write API's that support any type, yet enforced type safety at compile time. Awesome, right?<br /><br /><b>Pragmatism gets in the way</b><br />There are two serious flaws and one minor issue with generics.<b></b><br /><b><br /></b><b>Minor issue: </b>Generics only work at "compiler time". It is possible to break generics at runtime. This may sound like it is more than a "minor" issue, but see below.<br /><br /><b>Flaw #1:</b> Adding generics to code makes it more verbose, more difficult to read, and reduces productivity.<br /><br /><b>Flaw #2:</b> In over 12 years I've performed many hundreds of Java code reviews and observed thousands of bugs reports.<i> In all this time, I have never seen a bug that generics would have prevented.&nbsp; </i>I'm sure there have been some, but I haven't seen any.<br /><br /><b>Trade-off </b><br />The trade-off is reduced productivity, less readable code and more verbose code, to prevent an issue that never happens. Yet <i>every Java shop I know of requires generics</i>!<br /><br />What sounded like a good idea, in my view, has only hurt the language.<br /><b><br /></b><b>Annotations</b><br />We've had tools<b> </b>for some time that read specially formatted comments and generated metadata. One flaw of these tools was that the metadata was not available at runtime, since comments were stripped off by the compiler. But the tools provided useful benefit.<br /><br />Annotations can be compiled amd available at runtime. And they act as nice ways to act as signals to frameworks and tools to alter or enhance program behavior, thus reducing boilerplate code, which is generally good.<br /><br />But they do not do this without a cost. By using Annotations, we are creating a tight coupling to the framework or tool that is providing the enhancements.<br /><br />The advance that the Spring framework introduced was to leverage simple POJO's that were wired by the framework, without the need for each class to have a reference to Spring. This is about as decoupled as you can get.<br /><br />What this does is reduce the effort to switch frameworks. It has other benefits as well, for example, when looking as a Spring-based application, you usually can read the Spring configuration files and you'll have a single place to observe object relationships and other critical design decisions.<br /><br />Even the Java community saw this problem, and they tried to create a set of "generic" annotations to manage that tight coupling, but that effort failed.<br /><br />So annotations come with a price, and it seems an odd price to pay in light of the advanced Spring brought us.<br /><br />For those who complain about maintaining XML metadata files, Grails and Rails provided minimal or no XML configuration by implementing "Convention over Configuration", which further reduced boiler plate code, and was useful as long as the rules of convention were well understood, which was not always the case.<br /><br />So the future is exciting, but less predictable than it was just a few years ago. In this state, many shops are just sticking to Java, despite the fact Java does not always seem to be aging well.<br /><br /><br />Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-16859799705611773572012-03-05T21:34:00.001-06:002012-03-05T21:35:50.621-06:00The History of Computers: Computer War HumorA friend recently asked "what's the difference between c# and Java"? I'm sure he is sorry now.<br /><br />I began, "You see, c# is the main language for .net, a Microsoft product for building Web Applications. It is a lot like Java, but with more hand holding. It's used by small companies run by ex-bullies who don't want to pay their 'nerd-programmers' a good salary."<br /><br />I added "Recent surveys show that Java has 60% of the market compared to 40% for .net."<br /><br />Friend: "Uh, OK, but what about PHP? I've seen a lot of jobs advertised for PHP."<br /><br />Me: "Oh yeah, almost forgot about that. PHP is used for personal sites, internet porn, and by tiny companies that cannot afford a real programmer!"<br /><br />Friend: "Well, I'm not so sure about that..."<br /><br />Me: "Listen chump. I'm the expert here. But I'll give you a break. You're young, green and just opening your childlike eyes to that big, scary world out there."<br /><br />Friend: "I'm 34, and..."<br /><br />Me: "Never mind. Just listen hear and I'll fill you in with all that happened while you were just a sparkle in your fathers eye."<br /><br />"It's like conservatives versus liberals. MS is the big, evil conservative corporation bent on world domination. It treats you nice when it needs you, then it chews you up and spits you out."<br /><br />"On the other hand Java is the liberal, free, open source, pot smoking hippy alternative. They give you things for free! Group hug anyone?"<br /><br /><br />Friend (looking at watch): "I really have to..."<br /><br />Me (ignoring my friend for his own good):<br /><br />It started in the 50's and 60's with "big iron" mainframe manufacturers: IBM, Burroughs, UNIVAC, NCR, Control Data, Honeywell, General Electric and RCA.<br /><br />Competition was robust. Then wars ensued. Many lives were lost. IBM crushed their rivals leaving nothing but smoking scrap metal in the dust.<br /><br />IBM was the evil monster, and we all had to obey. But then it adopted and fed Microsoft, who grew and grew and grew. MS got so big it began to challenge IBM. You'd think taking down the evil giant would be a good thing. But the child was even more evil. It too was bent on world domination. And it was succeeding. IBM became the underdog.<br /><br />A new era began. The internet era. MS was preparing to finish off it's competitors. But then, in true American fashion, the rebels bravely picked a hero, a little platform called Java, and lined up behind it.<br /><br />Battle lines were drawn. Microsoft and its followers on one side, Java and its allies on the other. The battle looked to be fierce and bloody.The industry prepared for war. Bomb shelters were dug, canned food hoarded, dogs were fed.<br /><br />But then, wait for it, a new hero emerged! From the deep, cavernous tunnels, below a respected American educational institution, a thin, long haired, figure emerged pronouncing "free, as in free beer".<br /><br />Friend (waking up): "What?"<br /><br />Richard Stallman. He said software represents information, and it should available to the public. This led to open source software, often available for free, and often of much higher quality than its commercial counterparts.<br /><br />The Java folks rallied around this novel idea. Businesses developed models to give away software while monetizing ancillary offerings. Even the .net folks have started adopting open source.<br /><br />Friend: "So they won?"<br /><br />Me: The battle continues. However it is now a battle for hearts and minds. We freely invite our enemies to our homes and offices. We break bread together, and occasionally slice each others tires. But it's all in fun.<br /><br />Friend: "So what about Rails versus Grails?"<br /><br />Me (brandishing knife): "How dare you! Get out you scurvy dog, before I slash you a new one!"<br /><br />Me (alone at night, sipping a glass of fine brandy) "Sigh. Gotta love the language wars."Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-49963741909693845912011-05-08T20:42:00.000-05:002011-05-08T20:42:04.225-05:00Economies of Open SourcePerhaps the most unexpected success story of the last decade is the proliferation of open source software.<br /><br />When Richard Stallman began touting his ideas regarding free software (free as in free beer) many viewed this as idealistic. Of course Stallman had no issues about getting paid to write software. His assertion was that software represented information that should be shared. It was expected at this time that open source software would play at most a minor role in mainstream development.<br /><br />Historically software vendors vigorously guarded their source code to maintain competitive advantage. What we know today is availability of source code is an asset to developers, while competitors are only slightly hindered due to modern code dis-assemblers.. <br /><br />Linksys made history by opening their source code, which spawned a mini-industry of firmware upgrades that fueled sales of their hardware. Linksys effectively changed their revenue model from a hardware/firmware offering to a hardware solution with a basic operating system that users can easily upgrade, often for free.<br /><br />Vendors are exploring other revenue models that, for instance, combine open source software with enhancements (e.g. IBM Websphere) or offer support and consulting (e.g. SpringSource). <br /><br />Whether you like the idea of Open Source or not, odds are that just about any modern application makes use of some Open Source software. .NET developers are adopting open source tools like nHibernate and Spring.net. Look under the wraps at IBM's Websphere and you will find it is largely based on Open Source solutions.<br /><br />The reason is that in many domains, Open Source solutions now offer industry best solutions. This seems to be a contradiction to all things we learned about free market economics. How can free software compete with commercial solutions?<br /><br />The answer is quite simple: marketing. We take for granted that a vendor needs to peddle their wares. Competition results in better products for the consumer, however sales teams skew the picture to gain competitive advantage. <br /><br />In general Open Source solutions have no marketing, no sales teams, no slick presentations. The community vets these solutions, allowing <b>the best</b> to bubble to the top. It is the <i>lack of marketeers</i> that allow Open Source solutions to compete on merit alone, and that has resulted in today's plethora of high quality Open Source options.<br /><br />Perhaps the most common misunderstanding is about how Open Source solutions as funded. Certainly some are created out of passion, career enhancement or ego fulfillment. However Microsoft has performed so well that competitors now fund the Open Source community. In fact most large vendors have paid positions that contribute either part or full time to the community.<br /><br />It will be interesting to see what the future holds for the Open Source community. In the meantime, enjoy the riches available now, and contribute back to the community if you have the chance.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-46066051983337029252010-07-03T15:14:00.002-05:002010-07-03T15:18:52.231-05:00Architecture in the EnterpriseRecently I heard about a consulting company that sent a prospect to interview for an Enterprise Architect role. The interviewer, resume in hand, zeroed in on the lack of EA experience. Unfortunately the folks who set this up never identified this as an Enterprise Architect role. The prospect was a software architect, not an Enterprise Architect.<br /><br />Unfortunately some managers in recent years have appropriated the term 'architect' after running out of titles for the senior developers. Senior-senior developer? Master developer? Guru developer? I must admit, 'architect' sounds better.<br /><br />In reality architecture is a set of disciplines, each unique and specific. Beware of the unmodified term "architect", it has no meaning without context.<br /><br />In my experience, I have seen the following architecture roles:<br /><br /><b>Enterprise Architect</b><br />Enterprise architecture is performed at the strategic level. Typically EA's plan future-state architectures for the enterprise. They do no development at all and actual development experience is helpful but not necessary. EA's can provide competitive advantage over the long run. They can also bring an enterprise to it's knees. <br /><b> </b><br /><b>Technical (or Solution) Architect</b><br />This is a project-level position that recommends the hardware best suited for an application or system of applications. Actual development experience is helpful but not necessary.<br /><b><br /></b><br /><b>Chief Architect</b><br />In the mid-late 1990's architects were seen as overhead, but motivation existed for CIO's to have an architect. This would be a very senior person, essentially the only named architect in the enterprise. Nowadays Chief Architect is sometimes used to designate the top architect, or can be just a ceremonial title.<br /><b><br /></b><br /><b>Application Architect</b><br />Works at the project level, typically overseeing all technical aspects of the project. This is the original "architect", responsible for frameworks and design, aka "software architecture". Typically promoted from Technical Lead, the best AA's have been know to improve developer productivity by 2 times or more.<br /><br /><b>Network, Security, Data, Infrastructure, etc. Architects</b><br />These are technology-specific professionals who create enterprise standards, assist development teams and provide governance. They are responsible for their specific technical space, ensuring it meets project and enterprise requirements.<br /><br /><b>Summary</b><br />Each architecture role aligns with Enterprise Architecture and strategic business initiatives. For example, years before the current services trend, good application architects would design to support services, since future state architectures were likely to move to a Services Orientated Architecture.<br /><br />Each architecture role is fairly specific with little overlap. They are specialists who help tame the complexity required of enterprise solutions through standards, governance and best practices. Some can play multiple roles with training and experience, but they are generally not interchangeable.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-45278583349584996252010-03-09T14:42:00.002-06:002011-05-08T20:48:35.384-05:00Chicago Groovy User Group - March 2010I am giving a talk on "recipes" at the March 9, 2010 Chicago Groovy User Group (www.cgug.org).<br /><br />The Powerpoint may be found <a href="http://www.weimerweb.com/The%20Recipe%20Talk.pptx">here</a>.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com2tag:blogger.com,1999:blog-7546437942865144565.post-71874308533019657722009-12-14T11:22:00.001-06:002010-07-03T15:16:21.569-05:00Testing the Grails JAMon PluginPreviously I wrote about creating a JAMon plugin for Grails. Today I'll add some tests.<br /><br />Since a plugin is a Grails application, you should add tests to your plugin project. Let's begin with opening a command window in the plugin project (jamon) and creating a test class:<br /><br /><div class="code"><pre>grails create-integration-test JamonGrailsPlugin</pre></div><br />Now we edit the class Grails created. We find this class in jamon\test\integration\JamonGrailsPluginTests.groovy.<br /><br />First we see Grails creates a class that extends GrailsUnitTestCase. Since this is an integration test, we'll change it to extend GroovyTestCase instead. Let's add a few handy imports as well:<br /><br /><br /><div class="code"><pre>import grails.test.*<br /><br />import org.codehaus.groovy.grails.commons.ApplicationHolder<br />import org.codehaus.groovy.grails.commons.GrailsApplication<br />import javax.sql.DataSource<br /><br />class JamonGrailsPluginTests extends GroovyTestCase {</pre></div><br />I'll add a couple variables for brevity sake:<br /><br /><div class="code"><pre>def app = ApplicationHolder.application<br />def ctx = app.mainContext</pre></div><br />Next we'll add the boiler plate setUp and tearDown methods. I like <a href="http://joe.truemesh.com/blog/archives/agile/000047.html">AgileDox </a>naming so I'll override getName() as well:<br /><br /><div class="code"><pre>protected void setUp() {<br /> super.setUp()<br /> }<br /><br /> protected void tearDown() {<br /> super.tearDown()<br /> }<br /> <br /> public String getName() {<br /> return super.getName().substring(4).replaceAll("([A-Z])", " \$1").toLowerCase();<br /> }</pre></div><br />This first test will be to verify the dataSources have been updated with the jamon proxy:<br /><br /><div class="code"><pre>void testDataSourcesAreJamonEnabled() {<br /> ctx.getBeanNamesForType(DataSource).each{ beanName -&gt;<br /> def bean = ctx.getBean( beanName )<br /> assertEquals "com.jamonapi.proxy.JAMonDriver", bean.driverClassName<br /> assert bean.url.startsWith("jdbc:jamon:")<br /> assert bean.url.contains('jamonrealdriver=')<br /> }<br /> }</pre></div><br />We make use of the Spring method getBeanNamesForType() to get all beans subclassed from DataSource, then simply test the attributes we attempted to set.<br /><br />To verify that jamon is configured in the Spring context, we need a class in the plugin, such as a service class, to verify it is included in autoProxyCreatorBean. We can add a service by the grails command 'grails create-service jamonTest'. Of course we do not want the class added to our target applications, so we add the classname to the pluginExcludes variable in JamonGrailsPlugin:<br /><br /><div class="code"><pre>def pluginExcludes = [<br /> "grails-app/views/error.gsp",<br /> "grails-app/services/JamonTestService.groovy"<br /> ]</pre></div><br />Now we can code out test:<br /><br /><div class="code"><pre>void testJamonHasSpringAop() {<br /> assertNotNull ctx.getBean("jamonInterceptor")<br /> def autoProxyCreatorBean = ctx.getBean("autoProxyCreator")<br /> assertNotNull autoProxyCreatorBean<br /> assertArrayEquals (["jamonTestService"].toArray(), autoProxyCreatorBean.beanNames.toArray()) <br /> }</pre></div><br />The remaining tests can be coded in a similar fashion. It is a good idea to include tests for all the plugin behaviours as well as any bugs that creep up over time.<br /><br />That is it for the JAMon series. Hope these articles saved you some time. Your comments are encouraged!Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-12415201271484972362009-11-22T14:33:00.082-06:002010-07-03T15:16:40.808-05:00JAMon plugin for Grails: Part 4 of 4In this series we completed steps 1-4 of our task list:<br /><ol><li>Add jamon.jar to the application classpath</li><li>Use JAMon's datasource proxy to monitor SQL<br /></li><li>Implement the JAMonServletFilter to monitor page hits<br /></li><li>Leverage Spring AOP via Spring's JamonPerformanceMonitorInterceptor class to monitor services</li><li>Add a Spring filter to monitor Grails controllers</li></ol>Now lets complete step #5: Add a Spring filter to monitor Grails controllers. Spring filters are different than Servlet filters, although the details are beyond the scope of this article. Grails makes it easy to add Spring filters. Read the Grails documention for the details.<br /><br />Create a package structure under grails-app/conf. I used org/grails/plugins/filters. Create a file named JamonFilters and add the following code:<br /><br /><div class="code"><pre>package org.grails.plugins.filters<br /><br />import com.jamonapi.MonitorFactory<br />import com.jamonapi.Monitor<br />import org.codehaus.groovy.grails.commons.ConfigurationHolder<br />/**<br /> * @author eric weimer<br /> */<br /> class JamonFilters {<br /> <br /> Monitor monitor, viewMonitor, previewMonitor<br /> def skipControllers = (ConfigurationHolder.config.jamon.controllersToExclude)? ConfigurationHolder.config.jamon.controllersToExclude: []<br /> def filters = {<br /><br /> monitorController(controller: "*", action: "*") {<br /> before = {<br /> if (!(controllerName in skipControllers)) {<br /> def monName = "Controller.${controllerName}.${actionName}"<br /> monitor = MonitorFactory.start("${monName}")<br /> previewMonitor = MonitorFactory.start("${monName}.noview")<br /> }<br /> true<br /> }<br /> after = {<br /> if (previewMonitor) {<br /> previewMonitor.stop()<br /> def monName = "Controller.${controllerName}.${actionName}.view"<br /> viewMonitor = MonitorFactory.start("${monName}")<br /> }<br /> true<br /> }<br /> afterView = {<br /> if (monitor) monitor.stop()<br /> if (viewMonitor) viewMonitor.stop()<br /> true<br /> }<br /> }<br /> }<br />}</pre></div><br />This code calls JAMon methods to start and stop timings. Note the variable <i>skipControllers</i>. This allows users of the plugin to easily define a list of controllers NOT to monitor by adding the variable <br /><i>jamon.controllersToExclude</i> to groovy.config.<br /><br />This is all you need to do! Grails will add this filter to the application when you install the plugin. <br /><br />To allow users to provide additional customizations to the plugin, we document some configuration settings they can set, and then access those settings in our plugin. For example, in the application's Config.groovy class, let's allow users to specify the following:<br /><br /><div class="code"><pre>jamon.monitorControllers = true<br />jamon.monitorServices = true<br />jamon.servicesToExclude = ['consoleService']<br />jamon.controllersToExclude = []<br />jamon.additionalBeans = ['com.eweimer.terrapin.util.MediaAccess','com.eweimer.terrapin.util.Key']</pre></div><br />These settings will allow users to turn off monitoring for Controllers or Services, and specify services NOT to monitor as well as additional Spring beans classes to include.<br /><br />To access these values in our JamonGrailsPlugin, we'll import:<br /><br /><div class="code"><pre>import org.codehaus.groovy.grails.commons.ConfigurationHolder</pre></div><br />To perform a safe test on a boolean value we can use the following code to default to true when the user does not specify a value:<br /><br /><div class="code"><pre>def skipServices = application.config.jamon.servicesToExclude ?: []</pre></div><br />Put together, the code now looks like this:<br /><br /><div class="code"><pre>def monBeanNames = []<br />def skipServices = application.config.jamon.servicesToExclude ?: []<br /> <br />if (application.config.jamon.monitorServices ?: true) {<br /> monBeanNames = application.serviceClasses.collect{ it.shortName[0].toLowerCase() + it.shortName[1..-1] }<br /> monBeanNames -= skipServices<br />}<br />if (application.config.jamon.additionalBeans) {<br /> monBeanNames += application.config.jamon.additionalBeans<br />}</pre></div><br />By using this logic we can allow users to easily customize the behavior of our jamon plugin.<br /><br />The final step is to deploy your plugin. Type "grails package-plugin" in the root of your plugin project and Grails will create a .zip file. Then go to your Grails application and type "grails install-plugin <i>path-to-your-zip-file</i>", and you are ready to go.<br /><br />Deploy the jamon.war that comes with the JAMon distribution to your web server then point your browser to /jamon/menu.jsp to view the results. Viola!<br /><br />I hope you enjoyed this series. I'll add one more installment about testing your plugin when I have the chance. Meanwhile, have fun!Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com3tag:blogger.com,1999:blog-7546437942865144565.post-87277131891456317112009-11-22T14:01:00.050-06:002010-07-03T15:16:57.523-05:00JAMon plugin for Grails: Part 3 of 4In this series we completed steps 1-3 of:<br /><ol><li>Add jamon.jar to the application classpath</li><li>Use JAMon's datasource proxy to monitor SQL<br /></li><li>Implement the JAMonServletFilter to monitor page hits<br /></li><li>Leverage Spring AOP via Spring's JamonPerformanceMonitorInterceptor class to monitor services</li><li>Add a Spring filter to monitor Grails controllers.</li></ol>Let's move on to step 4 : "Leverage Spring AOP via Spring's JamonPerformanceMonitorInterceptor class to monitor services."<br /><br />We'll add this to the doWithSpring closure. First we'll define a jamonInterceptor bean. It accepts a prefix attribute, which can be set to anything you like:<br /><br /><div class="code"><pre>def doWithSpring = {<br /> jamonInterceptor( org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor, true, true ) {<br /> prefix="Class."<br /> }<br />}<br /></pre></div>Next we need to get a list of beans to intercept. Service class beans are named by the class name with the first character set to lower case. Grails provides a list of service classes via the application object:<br /><br /><div class="code"><pre>def monBeanNames = application.serviceClasses.collect{ it.shortName[0].toLowerCase() + it.shortName[1..-1] }</pre></div>Finally we use Springs BeanNameAutoProxyCreator to add the jamon interceptor to the service classes:<br /><br /><div class="code"><pre>if (monBeanNames) {<br /> autoProxyCreator( org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator ) {<br /> proxyTargetClass="true"<br /> interceptorNames=["jamonInterceptor"]<br /> beanNames=monBeanNames as String[]<br /> }<br />}</pre></div><br />Put it all together, it looks like this:<br /><br /><div class="code"><pre>def doWithSpring = {<br /> def monBeanNames = application.serviceClasses.collect{ it.shortName[0].toLowerCase() + it.shortName[1..-1] }<br /><br /> if (monBeanNames) {<br /> jamonInterceptor(org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor, true, true) {<br /> prefix="Class."<br /> }<br /><br /> autoProxyCreator(org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator) { <br /> proxyTargetClass="true"<br /> interceptorNames=["jamonInterceptor"]<br /> beanNames=monBeanNames as String[]<br /> }<br />}</pre></div><br />In part 4 of this series, we'll complete task #5 and deploy our JAMon plugin.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-87137816965392778552009-11-22T13:45:00.004-06:002010-07-03T15:17:13.725-05:00JAMon plugin for Grails: Part 2 of 4In part 1 we discussed four tasks needed to create a JAMon plugin. The first task was completed simply by adding jamon.jar to our plugin's lib folder. To review, the steps are:<br /><ol><li>Add jamon.jar to the application classpath</li><li>Use JAMon's datasource proxy to monitor SQL<br /></li><li>Implement the JAMonServletFilter to monitor page hits<br /></li><li>Leverage Spring AOP via Spring's JamonPerformanceMonitorInterceptor class to monitor services</li><li>Add a Spring filter to monitor Grails controllers.</li></ol>As I mentioned previously, our plugin project has a file named: JamonGrailsPlugin.groovy. This is where we'll implement steps 2-5.<br /><br />JamonGrailsPlugin.groovy comes with a series of closures pre-defined. To change the datasource we add code to the doWithSpring closure. This closure allows you to update your Spring configuration.<br /><br />We need to change the driverClassName to "com.jamonapi.proxy.JAMonDriver" and alter the url by adding "jamon:" after "jdbc:" and appending a parameter named "jamonrealdriver".<br /><br />First lets add an import:<br /><br /><div class="code"><pre>import javax.sql.DataSource</pre></div>Then code the closure:<br /><br /><div class="code"><pre>def doWithSpring = {<br /> def config = application.config<br /> def orgUrl = config.dataSource.url<br /> def driverClassName = config.dataSource.driverClassName<br /> <br /> String appendUrl = (orgUrl.contains('?')? '&amp;': '?') + 'jamonrealdriver=' + driverClassName<br /> if (orgUrl.contains("oracle:")) appendUrl = 'jamonrealdriver=' + driverClassName<br /> def url = orgUrl.replace("jdbc:","jdbc:jamon:") + appendUrl<br /><br /> config.dataSource.url = url<br /> config.dataSource.driverClassName = "com.jamonapi.proxy.JAMonDriver"<br />}</pre></div><br />Step 3 is "implement the JAMonServletFilter to monitor page hits."<br /><br />The doWithWebDescriptor closure will allow us to add our filter to the application. We need to append to both the &lt;filter&gt; and &lt;filter-mapping&gt; sections. Note that this is typical Grails builder code. The 'filter-mapping' node needs to be in quotes due to the hyphen in it's name:<br /><br /><div class="code"><pre>def doWithWebDescriptor = { webXml -&gt;<br /> def filters = webXml.filter<br /> filters + {<br /> filter {<br /> 'filter-name'("jAMonServletFilter")<br /> 'filter-class'("com.jamonapi.http.JAMonServletFilter")<br /> }<br /> }<br /><br /> def filterMappings = webXml.'filter-mapping'<br /> filterMappings + {<br /> 'filter-mapping' {<br /> 'filter-name'("jAMonServletFilter")<br /> 'url-pattern'("/*")<br /> }<br /> }<br /> }</pre><pre>} <br /></pre></div>In part 3 we'll move on to step #4.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-37044419069686653312009-11-22T12:01:00.006-06:002010-07-03T15:18:12.507-05:00Jamon plugin for Grails: Part 1 of 4<a href="http://jamonapi.sourceforge.net/">JAMon</a> is a popular, flexible, lightweight open source Java performance monitor. I won't cover all the features here, but in short JAMon can monitor performance, memory, number of users, basically any quantity you can access in Java.<br /><br />To view the statistics JAMon provides a WAR file that you can deploy to your server along with your application. The war provides a set of JSP pages allowing you to view and export the data you are monitoring.<br /><br />Another option is to incorporate the WAR into your application. It requires a little more work but you can enhance it to your hearts content.<br /><br />Adding JAMon to Grails is really quite simple. What required some time was to experiment with the different methods JAMon can be inserted into your application. I prefer automation over hard-coded solutions.<br /><br />Here are the tasks needed to get JAMon set up with an initial set of monitors:<br /><ol><li>Add jamon.jar to the application classpath</li><li>Use JAMon's datasource proxy to monitor SQL<br /></li><li>Implement the JAMonServletFilter to monitor page hits<br /></li><li>Leverage Spring AOP via Spring's JamonPerformanceMonitorInterceptor class to monitor services</li><li>Add a Spring filter to monitor Grails controllers.<br /></li></ol>Ideally it would be nice to separate this code in a way that JAMon could be applied to any Grails project. In fact, I found that to be the simplest approach! This solution just cries out for a Grails plugin.<br /><br />I won't go into all the details regarding plugins. Good references are available <a href="http://grails.org/doc/latest/guide/12.%20Plug-ins.html">here</a>, <a href="http://www.ibm.com/developerworks/opensource/library/j-grails09159/index.html">here</a> and <a href="http://www.theserverside.com/news/thread.tss?thread_id=47680">here</a>.<br /><br />Fist download the <a href="http://jamonapi.sourceforge.net/">JAMon</a> distribution and unzip it.<br /><br />Assuming you have a target application, let's assume you'll be creating your plugin in the same workspace (i.e. directory). Open a command prompt in that folder and type:<br /><br />grails create-plugin jamon<br /><br />If you've never created a plugin before you'll notice that Grails creates a typical Grails application with one additional file in the top directory: JamonGrailsPlugin.groovy.<br /><br />This file is where we'll be doing most of the work.<br /><br />To complete task #1 (add jamon.jar to the classpath), simple copy jamon.jar to jamon/lib. When an application installs the plugin, Grails will add jamon.jar to the classpath. That's all you need to do!<br /><br />Next time I'll show how to implement the remaining tasks. Stay tuned.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-78723234737026724222009-11-20T22:44:00.012-06:002010-07-03T15:18:26.301-05:00JAMonYears ago I discovered a little gem in the world of a free and open source software: <a href="http://jamonapi.sourceforge.net/">JAMon</a>.<br /><br />Still in use today, JAMon's mind-numbingly simple API provides a wealth of value for minimal effort. JAMon has now spawned competing products, each with its unique pros and cons.<br /><br />JAMon is called a lightweight monitor. This may disappoint those who prefer large, feature-filled enterprise level commercial products, but the reality is JAMon delivers most of the data you need with <span style="font-style: italic;">minimal impact on performance</span>. I would never consider developing a Java application without JAMon or some other monitoring solution. (JAMon is available for other languages as well.)<br /><br />Best of all, you can have JAMon up and running in a few hours (or less)!<br /><br />JAMon excels at timing code execution. Without any code changes you can configure JAMon to monitor SQL, method calls (via Spring AOP), as well as application entry and exit points.<br /><br />In addition to execution time, JAMon allows you to monitor ANY data that can be expressed numerically. Common usage includes the number of users by hour of the day (to find usage peaks), simultaneous users, memory, heap size, session size, # of active sessions, and so on.<br /><br />JAMon accumulates statistics rather than details which allows it to minimize its memory footprint. As it turns out, that is an excellent comprimise. JAMon keeps track of the number of invocations, min, max, average and standard deviation, as well as the min, max and average number of simultaneous executions, which is great for bottleneck analysis.<br /><br />Although criticized for its inability to save statistics to a persistent store, you can do so with a little work if needed. You can persist statistics to a database, log file, expose them via JMX, etc.<br /><br />You can configure JAMon start and stop monitoring dynamically. JAMon is typically measured at less than one percent overhead while turned on, and much less when turned off.<br /><br />So if you have no monitoring (or your monitoring solution cannot be run in production), try JAMon or one of it's competitors. Documentation is a bit on the light side but there are plenty of examples on the Web.<br /><br />And if you are a Grails developer, look for my posts about how to create a simple plugin to enable JAMon in your Grails applications.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-27032314692353298202009-09-25T01:06:00.004-05:002009-09-25T01:32:50.387-05:00Grails TweetsSven Haiges of <a href="http://www.grailspodcast.com/">grails podcast</a> fame has created a Groovy/Grails/Griffon tweet aggregator that allows users to "re-tweet" important tweets, providing a community-based, self-organizing tweet prioritizing tweeting community (Getting dizzy. I should tweet about that.)<br /><br />Check out <a href="http://www.groovytweets.org/">http://www.groovytweets.org/</a>.<br /><br />Not satisfied with this, Sven created a nice "Headline Animator" that you can place on any html page to view the "important" tweets. This is one of three variations:<br /><br /><br /><p style="margin-top: 10px; margin-bottom: 0pt; padding-bottom: 0pt; text-align: center; line-height: 0pt;"><a target="_blank" href="http://feeds.feedburner.com/%7Er/importantgroovytweets/%7E6/3"><img src="http://feeds.feedburner.com/importantgroovytweets.3.gif" alt="groovytweets ::: important tweets" style="border: 0pt none ;" /></a></p><p style="margin-top: 5px; padding-top: 0pt; font-size: x-small; text-align: center;"><a href="http://feedburner.google.com/fb/a/headlineanimator/install?id=poj4rupefrgj6m7i2imh4c5gck&amp;w=3" onclick="window.open(this.href, 'haHowto', 'width=520,height=600,toolbar=no,address=no,resizable=yes,scrollbars'); return false" target="_blank">↑ Grab this Headline Animator</a></p><br /><br />DankeEric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-31325081424231691022009-09-24T21:10:00.006-05:002010-07-03T15:19:23.590-05:00The Business of IT - ROI and CBATwo common tools businesses use to aid decision making are Return on Investment (ROI) and Cost Benefit Analysis (CBA). Use these tools to help sell your ideas to your management.<br /><br />ROI is used when "spending money to save money". The analysis is simple and the result is a period of time, often expressed in months.<br /><br />Simply start with the amount you spend, add up your savings over time, and see when they net out. That will be your ROI. Everything after the ROI is savings, so the analysis typically presents a few years into the future to highlight how much money you'll be ahead (and how clever you are).<br /><br />Depending on your management, a simple analysis may be close enough, or they may want a more thorough analysis that includes the time-value of money (i.e. the investment income you'll lose by spending it), tax ramifications and other costs expressed as "present value".<br /><br />In that case, delegate to that staffer who whines when they do not get promoted each and every review.<br /><br />Cost Benefit Analysis (CBA) is when you weigh expected costs versus expected benefits of one or more options to choose the best one. Both costs and benefits are expressed in money and may be a simple calculation or may include the time value of money expressed as "present value".<br /><br />With a CBA benefits need not be restricted to typical expense and revenue concerns such as staff reduction. CBA's can include myriad benefits such as market presence, public relations, recruiting, industry and financial analysts, community contributions, carbon footprint, green initiatives, etc. etc.<br /><br />Here it pays to include all realistic benefits.<br /><br />Any business analysis must be compelling to be useful, and must be clearly communicated to be compelling. Back up your analysis with industry accepted measures and you'll earn a reputation for "doing your homework" before presenting to management.<br /><br />CheersEric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-46043028361394536112009-03-31T01:45:00.001-05:002010-07-03T15:20:03.007-05:00Problem ResolutionI observed a small team that included a very talented developer. They were asked to solve a very nasty production performance issue.<br /><br />The developer had a "gut feeling" for the problem and wanted to try his solution.<br /><br />This approach is akin to picking the <span style="font-style: italic;">low hanging fruit.</span><br /><br />To solve this type of issue, it is often wise to attempt to pick the <span style="font-style: italic;">low hanging fruit</span> and hope for a quick resolution.<br /><br />However you must limit your fruit intake. After a few tries, you need to resort to proper analysis and isolate the problem.<br /><br />After his initial effort failed, he again had another "gut feeling" and wanted to try for another quick fix. This pattern repeated itself several more times, until he gave up and quietly moved on.<br /><br />Unfortunately the <span style="font-style: italic;">low hanging fruit</span> was too appealing, and management was easily sold by the quick solution. The proper analysis was never done. The issue was never resolved.<br /><br />Gut feelings often result in brilliant work. When they fail, there must be proper analysis. <span style="font-style: italic;"></span>The pragmatic programmer must set aside emotionally-driven behaviors and use a more prudent approach.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-85367486099215723492009-03-31T01:00:00.001-05:002010-07-03T15:20:40.418-05:00Managing ComplexityI was once confronted by a well meaning tech lead who predicted a performance issue and was "enhancing" the design to circumvent the issue.<br /><br />After many years in this field I find it interesting that even very talented developers feel the need to fall prey to one of the oldest anti-patterns: <span style="font-style: italic;">premature optimization</span>.<br /><br />When I requested justification I discovered he had a "gut" feel this operation would take too long. No proof of concept had been done, no estimated timings, just the perception it would take "too long".<br /><br />For all I know he could be correct. But years of development have taught me to resist the urge and <span style="font-style: italic;">keep it simple</span>. Don't complicate designs until you know you have a real problem.<br /><br />My experience is that the vast majority of perceived performance issues never materialize. Assuming a well-designed architecture, simple designs perform well in the vast majority of cases.<br /><br />Keeping the design simple and focusing on performance enhancements when they become necessary allows developers to focus their efforts on real problems, rather than perceived issues.<br /><br />Don't design in complexity. Save it for when you really need it.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-75510830026650998012009-03-09T20:38:00.001-05:002010-07-03T15:20:55.109-05:00Chicago Groovy User GroupTomorrow I am presenting an intro to Groovy and Grails at the <a href="http://www.cgug.org/">Chicago Groovy User Group</a> monthly meeting.<br /><br />As usual I have a bad cold and am dead tired. However I'll give it my best effort since the organizers are all great guys and have put a lot of effort into getting this group off the ground.<br /><br />There will be free pizza and drinks. Best of all, raffle prizes!<br /><br />Slides of the talk are available in <a href="http://www.weimerweb.com/Groovy_and_Grails_Intr_dist.pptx">pptx</a> format as well as <a href="http://www.weimerweb.com/Groovy_and_Grails_Intr_dist.pdf">pdf</a>.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com1tag:blogger.com,1999:blog-7546437942865144565.post-74489202316241248812009-03-07T23:31:00.001-06:002010-07-03T15:21:47.057-05:00Syntactic Sugar<span style="font-style: italic;">Syntactic sugar</span> is a colorful expression that has been popping up in tech circles for the last few years. There is even a <a href="http://en.wikipedia.org/wiki/Syntactic_sugar">Wikipedia page for it</a>.<br /><br />Java contains a bit of syntactic sugar. All objects in Java are created through calls to the object model except one: String. Strings can be created directly through Java syntax.<br /><br />In Java we can create a String through the object model by calling a constructor:<br /><br />String name = new String ("eduardo");<br /><br />Or we can use this bit of "syntactic sugar":<br /><br />String name = "eduardo";<br /><br />As you can see, syntactic sugar gives us two things: clarity and conciseness. It usually does not add any new functionality.<br /><br />Groovy expands on syntactic sugar. This allows Groovy code to be expressive and concise. Multiply that by the thousands of lines of code a developer reads and it adds up to real productivity. (Of course, the time saved usually gets blown on things like writing blogs, etc.)<br /><br />Take the following Groovy syntax:<br /><br />(0..9).times {...}<br /><br />Even if you've never seen Groovy syntax it is quite obvious this is iterating from o..9. This is arguably clearer than the Java alternative:<br /><br />for (int i = 0; i &lt; 10; i++) { ... } Groovy makes great use of Syntactic sugar, allowing developers to express their intentions in a more concise and clear manner then legacy Java. Java simply cannot add many next generation features. Java is hampered by the need to be backwards compatible and it's lack of full object orientation. To remain competitive in the future we need to turn to a new language. My money is on <a href="http://groovy.codehaus.org/">Groovy</a>.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-32214363945519125342009-02-22T17:08:00.001-06:002010-07-03T15:21:23.310-05:00What is Groovy?What is <a href="http://groovy.codehaus.org/">Groovy</a>? Besides being music-inspired slang from the 1960's, Groovy is, in my view, the "next big thing" for the Java platform.<br /><br />Why, you may ask? Here are a few reasons:<br /><ol><li>Groovy is backward-compatible with Java, which translates to real business value.</li><li>Groovy is designed to allow developers to be more productive, which also adds real business value.<br /></li><li>Groovy has become wildly popular in the recent past.Recent <a href="http://today.java.net/pub/pq/143">polls</a> I've seen place Groovy as the most desired language by developers. In the open source world this fact is highly predictive.<br /></li><li>Ruby in the lead <span style="font-style: italic;">if you go by job postings</span>, and Ruby is an excellent language. However Java developers must learn an entirely new syntax. Groovy is based on Java syntax, making it an easier transition for legacy Java developers.</li><li>JRuby can run on the Java platform. However Groovy is built on top of Java and provides access to all the familiar Java api's. In fact Groovy enhances the Java object model, so in reality you are running not only on the Java platform, but you are running on Java standard classes.<br /></li><li>Groovy implements all the popular language constructs from Ruby, Smalltalk, Python and others, making it an excellent choice for the enterprise.</li><li>New features that show up in Ruby or Groovy are quickly implemented in each other language.<br /></li><li>Java is widely perceived to be near sunsetting. Any language can tolerate only so many enhancements until it acquires a reputation of feature bloat. </li><li>Groovy improves on Java. Syntactically, Groovy is clearer and more concise. And Groovy eliminates some of the the most common Java bugs.<br /></li><li>Grails, a popular application framework for Groovy, leverages RoR's "convention over configuration" approach, which further reduces the code developers need to write.</li><li>During the last 12 months, downloads of Grails have grown from 7,000 to 70,000 per month.</li><li>Groovy is 100% object-orientated, leaving Java compromises in the past forever.</li><li>Groovy and Grails are production ready now, and are showing up in more and more web sites.</li></ol>Whether you manage or work in a Java shop, you should be watching Groovy's progress very carefully. Your competition may already be making the jump.<br /><br />At this point, Groovy and Grails look like excellent bets for future development.Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0tag:blogger.com,1999:blog-7546437942865144565.post-8218657442079149842009-02-16T20:04:00.001-06:002010-07-03T15:21:07.900-05:00The problem with Java Primitives<span style="font-family: times new roman;">As a long time Java user I have developed a love for the language.<br /><br />At least until I found Groovy. Let me explain...</span> <span style="font-family: times new roman;"><br /><br />Smalltalk enjoyed a surge of popularity in the early 1990's when the "deep thinkers" of the industry proclaimed OO as the </span><span style="font-family: times new roman; font-style: italic;">next big thing.</span> <span style="font-family: times new roman;">However Smalltalk got stuck with a reputation of being "too slow".<br /><br />When Java was designed in the mid 1990's it utilized primitives like int, char, float, etc. for performance.</span> <span style="font-family: times new roman;">But if you think about it, here we have a mostly object-orientated language, where all comparison operators (&gt;, &lt;, ==, etc.) make sense with primitives, not objects!</span> <span style="font-family: times new roman;"><br /><br />Groovy designers, on the other hand, realized compiler technology and modern hardware utilize objects with excellent performance. However that leads to a quandary: how do we include operators in a way that makes sense?</span> <span style="font-family: times new roman;"><br /><br />The answer is operator overloading. But isn't operator overloading a bad thing? Didn't we learn that from C++?</span> <span style="font-family: times new roman;"><br /><br />Well, operator overloading can certainly be abused, but it is a natural way to allow operators to work in a fully object-orientated language.</span> <span style="font-family: times new roman;"><br /><br />Examine the following Groovy code:</span><br /><br /><span style="font-family: courier new;">public Boolean max(Integer i1, Integer i1) {<br />(i1 &gt; i2)? i1 : i2<br />}<br /><br /><span style="font-family: times new roman;">Even though i1 and i2 are objects of type Integer, this code works as expected. Why? Groovy overloads the '&gt;' operator to call the compareTo() method. For integers, this works since Groovy has added the compareTo method to make Integers work as expected.<br /><br /></span><span style="font-family: times new roman;">You see this all over the Groovy language. Instead of having to memorize Java's idiosynchronicies, Groovy works in an intuitive manner. Much like the Unix's RLS (Rule of Least Surprise), Groovy does what you expect.<br /><br />Now take what is agruably the most common Java bug: comparing two String objects with '=='. Not only does it compile cleanly but it fails intermittenly, which is the hardest type of failure to cure. Yet it looks fine, passes code reviews, and makes it to production systems all too often. Even experienced Java developers miss it.<br /><br />In Groovy, it just works. Groovy calls equals() when you use the '==' syntax. So now we have a language that not only is backward compatible with Java, but fixes common Java bugs!<br /><br />All I can say is "Groovy".<br /></span></span>Eric Weimerhttps://plus.google.com/111425432192914533236noreply@blogger.com0