Self-Reflection on Exception-Handling

9 01 2008

I spent this week on refactoring my code of past three months. It’s a torturous work. And the one which makes me want to tear my hair out, is Exception-Handing. I luckily followed almost all the Not-To-Do listed in <Exception-Handling Antipatterns> .

Actually Exception-Handling design have great influence on total quality.Bad Exception-Handling sometime ruin good design. I list here some guideline mentioned in <Toward Exception-Handling Best Practices and Patterns> .Make it right even if it goes wrong.

  • Don’t try to handle coding errors.
  • Avoid declaring lots of exception classes.
  • Name an exception after what went wrong, not who raised it.
  • Recast lower-level exceptions to higher-level ones whenever you raise an abstraction level.
  • Provide context along with an exception.
  • Handle exceptions as close to the problem as you can.
  • Assign exception-handling responsibilities to objects that can make decisions.
  • Use exceptions only to signal emergencies.
  • Don’t repeatedly rethrow the same exception.




50 Great CS Books Recommended by Book Pool

7 01 2008

1.Design Patterns: Elements of Reusable Object-Oriented Software
By Erich Gamma, et al

2.The Mythical Man-Month: Anniversary Edition
By Frederick P. Brooks Jr.

3.TCP/IP Illustrated, Volume 1: The Protocols
By W. Richard Stevens

4.Writing Secure Code, 2nd Edition
By Michael Howard, et al

5.Advanced Programming in the UNIX Environment, 2nd Edition
By W. Richards Stevens, et al

6.Code Complete, 2nd Edition
By Steve McConnell

7.The C Programming Language, 2nd Edition
By Brian W. Kernighan, et al

8.Art of Computer Programming Volumes 1-3 Boxed Set
By Donald Knuth

9.Effective C++: 55 Specific Ways to Improve Your Programs and Designs, 3rd Edition
By Scott Meyers

10.The Guru’s Guide to Transact-SQL
By Ken Henderson

11. Programming Perl, 3rd Edition
By Larry Wall, et al

12. Programming Pearls, 2nd Edition
By Jon Bentley

13. Pragmatic Programmer: From Journeyman to Master
By Andrew Hunt, et al

14. Extreme Programming Explained: Embrace Change, 2nd Edition
By Kent Beck

15. Don’t Make Me Think: A Common Sense Approach to Web Usability, 2nd Edition
By Steve Krug

16. Developing Microsoft ASP.NET Server Controls and Components
By Nikhil Kothari, et al

17. Security Engineering: A Guide to Building Dependable Distributed Systems
By Ross Anderson

18.

19. The Design of Everyday Things
By Donald A. Norman

20. Joel on Software
By Joel Spolsky

21. Internet Routing Architectures, 2nd Edition
By Sam Halabi, et al

22. Secrets & Lies: Digital Security in a Networked World
By Bruce Schneier

23. The Practice of Programming
By Brian Kernighan, et al

24. Designing with Web Standards
By Jeffrey Zeldman

25. Peopleware: Productive Projects and Teams, 2nd Edition
By Tom DeMarco, et al

26. The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography
By Simon Singh

27. Programming Windows, 5th Edition
By Charles Petzold

28. Mac OS X: The Missing Manual, Panther Edition
By David Pogue

29. The Elements of Style, 4th Edition
By William Strunk Jr., et al

30. In Search of Stupidity: Over 20 Years of High-Tech Marketing Disasters
By Merrill R. Chapman

31. Godel, Escher, Bach: An Eternal Golden Braid
By Douglas R. Hofstadter

32. Service-Oriented Architecture: A Field Guide to Integrating XML and Web Services
By Thomas Erl

33. Head First Java, 2nd Edition
By Kathy Sierra, et al

34. Introduction to Algorithms, 2nd Edition
By Thomas H. Cormen, et al

35. A First Look at SQL Server 2005 for Developers
By Bob Beauchemin, et al

36. Core Java 2, Volume 1: Fundamentals, 7th Edition
By Cay S. Horstmann, et al

37. UML Distilled: A Brief Guide to the Standard Object Modeling Language, 3rd Edition
By Martin Fowler

38. Expert Oracle, Signature Edition (One-on-One)
By Thomas Kyte

39. Hacking Exposed: Network Security Secrets & Solutions, 5th Edition
By Joel Scambray, et al

40. Microsoft SharePoint: Building Office 2003 Solutions
By Scot P. Hillier

41. Effective Java Programming Language Guide
By Joshua Bloch

42. Joe Celko’s SQL for Smarties : Advanced SQL Programming, 3rd Edition
By Joe Celko

43. Patterns of Enterprise Application Architecture
By Martin Fowler

44. Group Policy, Profiles, and IntelliMirror for Windows 2003, Windows XP, and Windows 2000
By Jeremy Moskowitz

45. Applied Cryptography: Protocols, Algorithms, and Source Code in C, 2nd Edition
By Bruce Schneier

46. Refactoring: Improving the Design of Existing Code (The Addison-Wesley Object Technology Series)
By Martin Fowler, et al

47. The C# Programming Language
By Anders Hejlsberg, et al

48. Pragmatic ADO.NET: Data Access for the Internet World
By Shawn Wildermuth

49. Computer Networks, 4th Edition
By Andrew S. Tanenbaum

50. DNS and BIND, 4th Edition
By Paul Albitz, et al





Java Performance

4 01 2008

Performance is critical to the success of an application.The user doesn’t not only require it runs right but also require it runs fast.So performance planning and analysis should be included in all the life cycle of development.

Actually performance relies on several factors:

  • Hardware
  • Software
  • Configuration
  • Cost
  • 3rd party system/libraries

But here I’ll only focus on software part.

Performance Planning

First, before starting the project, we should have a performance planning in mind.Performance should be an afterthought. Especially because architectural problem cause some performance problem can’t be fixed except redesign all the application. Following figure shows different levels of tuning.The most important part is on the bottom.

Figure clip_image001.gif

Finally: Beautiful code is fast code.





JMeter

3 01 2008

JMeter under Apache project is an application designed to load test C/S software.JMeter can be used to simulate a heavy load on a server , network or object to test its strength or to analyze overall performance under different load types.

 

After extracting JMeter on your computer, you can run it by jmeter.bat. To begin with JMeter, you need to build a test plan.A test plan describes a series of steps JMeter will execute when run. A complete test plan will consist of one or more Thread Groups, logic controllers, sample generating controllers, listeners, timers, assertions, and configuration elements.





Binding XML to Java Classes

16 10 2007

JAXB= java Architecture for XML Binding provide a convient way to bind between XML schemas and Java classes.

Architecture as following figure

Diagram of JAXB architecture, showing Schema on left, Schema Generator and Schema Compiler in the middle, and Application Code on the right.

when unmarshalling xml schemas to Java class , XML Schema is represented by classes derived from XML elements and an ObjectFactory class.





Essential scalability vocabulary

29 08 2007

I found a great article “Farms, clones, partitions, packs, RACS, and RAPS – Improve your scalability vocabulary” by Bill Devlin,Jim Gray,Bill Laing,George Spix from Microsoft. It summarize most main concepts I came across after weeks of reading on building a scalable system.

Two main ways of building a scalable system is cloning and partitioning.

Cloning offer both scalability and availability. But the problem with cloning is bad write performance and constrain of memory.

Partitioning divide data among nodes. It offer scalability. And availability can be achieved by replication data on a backup machine.But the problem with partitions is sometime it is difficult to do the partition in real life because of great dependences.

Following is the table of scalability taxonomy

Table of scalability taxonomy





Worse is Better

24 08 2007

Worse is Better, Many people will find it rather funny.However this philosophy does work. First introduced by Richard P.Gabriel in 1990, this theory occurs at all levels of scale.

In common sense :

  • First-to-Market Wins
  • The best technology Wins
  • The most innovative Wins

But in real world you may find the completist can’t bring home the bacon. Based on the worse is better theory , Gabriel created a model to transform technology into successful products. Some main point in this model is :

  • Don’t choose the most cutting edge technology,maybe 1o years out of the lab
  • Choose a technology that appeals to the needs of market
  • The design should have simplicity, minimal completeness,minimal correctness
  • The implementation should be small,fast,interoperated with existing product and bug-free

You can get more detailed informations in the page , and enjoy Gabriel’s sense of humor through all his








Follow

Get every new post delivered to your Inbox.