Search This Blog

Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, April 5, 2010

Static Code Analysis, Defect Detection, Code Smells, Architecture Smells, Dependency Analysis

FindBugs Descriptions
  • Bad Practice
  • Correctness
  • Experimental
  • Malicious Code Vulnerability
  • Multithreaded Correctness
  • Performance
  • Security
  • Dodgy Practices
PMD Rulesets

Lint4J checks for
JLint Program Checker
    Coverity Static Analysis, Dynamic Analysis , Architectural Analysis

    NASA's JPF (Java Path Finder)
    Which defects can be found by JPF? Out of the box, JPF can search for deadlocks and unhandled exceptions (e.g. NullPointerExceptions and AssertionErrors), but the user can provide own property classes, or write listener-extensions to implement other property checks. A number of such extensions, like race condition and heap bounds checks are included in the JPF distribution 

    Hammurabi Hammurapi is a code quality governance platform to mitigate risks of outsourcing* of software development.

    Structure 101

      Friday, March 5, 2010

      Programmer Productivity Tips

      1. Use a modern IDE such as Eclipse.
      2. Content Assist (or Code Completion, tab completion, Intellisense, etc.)  Content assist provides you with a list of suggested completions for partially entered strings. In Eclipse type something in the editor window and then ctrl-space. (e.g in Eclipse: Preferences->Java->Editor->Content Assist->Advanced)
      3. Code Templates: For example, type sysout and then ctrl-space and it spits out System.out.println(); with the cursor in the right spot. Type "for" ctrl-space and get a for...loop, type "try" ctrl-space and get a try...catch block.  (Eclipse: Window->Preferences->Java->Editor->Templates) 
      4. Code Generation: Faster Java coding in Eclipse Galileo (IBM), Useful Eclipse Shortcuts (SO) , Eclipse Shortcuts (Vogella)
      5. Compiler Warnings: Using Eclipse Java Compiler Errors/Warnings – Improving your code quality, CheckStyle
      6. Syntax Highlighting
      7. Focus (i.e. turn off email, browser, im when possible)
      8. Google
      9. Dual Monitors
      10. Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems
      11. Caffeine
      12. Debugger Java Debugging With Eclipse (Vogella)
      13. Sound isolating headphones
      14. Design Patterns
      15. XML Binding (no need to write DOM and SAX code any more)

      Monday, February 15, 2010

      Favorite Pragmatic Software Development Tips

      From The Pragmatic Programmer: From Journeyman to MasterThe Pragmatic Programmer: From Journeyman to Master
      See them all here.
      • DRY—Don’t Repeat Yourself
      • Always Use Source Code Control
      • Write Code That Writes Code
      • Design with Contracts
      • Refactor Early, Refactor Often
      • Abstractions Live Longer than Details
      • Don’t Use Manual Procedures
      • Test Early. Test Often. Test Automatically.
      • Use Exceptions for Exceptional Problems
      • Minimize Coupling Between Modules
      • Put Abstractions in Code, Details in Metadata
      • Design Using Services
      • Separate Views from Models
      • Don’t Program by Coincidence
      • Test Your Estimates
      • Design to Test
      • Find Bugs Once
      • Build Documentation In, Don’t Bolt It On

      Sunday, February 14, 2010

      Antipatterns (collected from wikipedia)

      Antipatterns (retrieved 2-14-10). Also see programming bugs.
      Organizational anti-patterns
      • Analysis paralysis: Devoting disproportionate effort to the analysis phase of a project
      • Cash cow: A profitable legacy product that often leads to complacency about new products
      • Design by committee: The result of having many contributors to a design, but no unifying vision
      • Escalation of commitment: Failing to revoke a decision when it proves wrong
      • Management by perkele: Authoritarian style of management with no tolerance for dissent
      • Moral hazard: Insulating a decision-maker from the consequences of his or her decision.
      • Mushroom management: Keeping employees uninformed and misinformed (kept in the dark and fed manure)
      • Stovepipe or Silos: A structure that supports mostly up-down flow of data but inhibits cross organizational communication
      • Vendor lock-in: Making a system excessively dependent on an externally supplied component

      Project management anti-patterns
      • Death march: Everyone knows that the project is going to be a disaster – except the CEO. However, the truth remains hidden and the project is artificially kept alive until the Day Zero finally comes ("Big Bang"). Alternative definition: Employees are pressured to work late nights and weekends on a project with an unreasonable deadline.
      • Groupthink: During groupthink, members of the group avoid promoting viewpoints outside the comfort zone of consensus thinking.
      • Smoke and mirrors: Demonstrating how unimplemented functions will appear
      • Software bloat: Allowing successive versions of a system to demand ever more resources

      Analysis anti-patterns
      • Bystander apathy: When a requirement or design decision is wrong, but the people who notice this do nothing because it affects a larger number of people.

      Software design anti-patterns
      • Abstraction inversion: Not exposing implemented functionality required by users, so that they re-implement it using higher level functions
      • Ambiguous viewpoint: Presenting a model (usually OOAD) without specifying its viewpoint
      • Big ball of mud: A system with no recognizable structure
      • Database-as-IPC: Using a database as the message queue for routine interprocess communication where a much more lightweight mechanism would be suitable
      • Gas factory: An unnecessarily complex design
      • Gold plating: Continuing to work on a task or project well past the point at which extra effort is adding value
      • Inner-platform effect: A system so customizable as to become a poor replica of the software development platform
      • Input kludge: Failing to specify and implement handling of possibly invalid input
      • Interface bloat: Making an interface so powerful that it is extremely difficult to implement
      • Magic pushbutton: Coding implementation logic directly within interface code, without using abstraction.
      • Race hazard: Failing to see the consequence of different orders of events
      • Stovepipe system: A barely maintainable assemblage of ill-related components

      Object-oriented design anti-patterns
      • Anemic Domain Model: The use of domain model without any business logic which is not OOP because each object should have both attributes and behaviors
      • BaseBean: Inheriting functionality from a utility class rather than delegating to it
      • Call super: Requiring subclasses to call a superclass's overridden method
      • Circle-ellipse problem: Subtyping variable-types on the basis of value-subtypes
      • Circular dependency: Introducing unnecessary direct or indirect mutual dependencies between objects or software modules
      • Constant interface: Using interfaces to define constants
      • God object: Concentrating too many functions in a single part of the design (class)
      • Object cesspool: Reusing objects whose state does not conform to the (possibly implicit) contract for re-use
      • Object orgy: Failing to properly encapsulate objects permitting unrestricted access to their internals
      • Poltergeists: Objects whose sole purpose is to pass information to another object
      • Sequential coupling: A class that requires its methods to be called in a particular order
      • Yo-yo problem: A structure (e.g., of inheritance) that is hard to understand due to excessive fragmentation
      Programming anti-patterns
      • Accidental complexity: Introducing unnecessary complexity into a solution
      • Action at a distance: Unexpected interaction between widely separated parts of a system
      • Blind faith: Lack of checking of (a) the correctness of a bug fix or (b) the result of a subroutine
      • Boat anchor: Retaining a part of a system that no longer has any use
      • Busy spin: Consuming CPU while waiting for something to happen, usually by repeated checking instead of messaging
      • Caching failure: Forgetting to reset an error flag when an error has been corrected
      • Cargo cult programming: Using patterns and methods without understanding why
      • Coding by exception: Adding new code to handle each special case as it is recognized
      • Error hiding: Catching an error message before it can be shown to the user and either showing nothing or showing a meaningless message
      • Expection handling: (a portmanteau of expect and exception) Using a language's error handling system to implement normal program logic
      • Hard code: Embedding assumptions about the environment of a system in its implementation
      • Lava flow: Retaining undesirable (redundant or low-quality) code because removing it is too expensive or has unpredictable consequences[5][6]
      • Loop-switch sequence: Encoding a set of sequential steps using a loop over a switch statement
      • Magic numbers: Including unexplained numbers in algorithms
      • Magic strings: Including literal strings in code, for comparisons, as event types etc.
      • Soft code: Storing business logic in configuration files rather than source code[7]
      • Spaghetti code: Systems whose structure is barely comprehensible, especially because of misuse of code structures
      Methodological anti-patterns
      • Copy and paste programming: Copying (and modifying) existing code rather than creating generic solutions
      • Golden hammer: Assuming that a favorite solution is universally applicable (See: Silver Bullet)
      • Improbability factor: Assuming that it is improbable that a known error will occur
      • Premature optimization: Coding early-on for perceived efficiency, sacrificing good design, maintainability, and sometimes even real-world efficiency
      • Programming by permutation (or "programming by accident"): Trying to approach a solution by successively modifying the code to see if it works
      • Reinventing the wheel: Failing to adopt an existing, adequate solution
      • Silver bullet: Assuming that a favorite technical solution can solve a larger process or problem
      • Tester Driven Development: Software projects in which new requirements are specified in bug reports
      Configuration management anti-patterns
      • Dependency hell: Problems with versions of required products
      • DLL hell: Inadequate management of dynamic-link libraries (DLLs), specifically on Microsoft Windows
      • Extension conflict: Problems with different extensions to pre-Mac OS X versions of the Mac OS attempting to patch the same parts of the operating system
      • JAR hell: Overutilization of the multiple JAR files, usually causing versioning and location problems because of misunderstanding of the Java class loading model

      Code Smells

      From Martin Fowler's excellent book, Refactoring: Improving the Design of Existing CodeRefactoring: Improving the Design of Existing Code. More descriptions can be found here.

      • Duplicated Code
      • Long Method
      • Large Class
      • Long Parameter List
      • Divergent Change
      • Shotgun Surgery
      • Feature Envy
      • Data Clumps
      • Primitive Obsession
      • Switch Statements
      • Parallel Inheritance Hierarchies
      • Lazy Class
      • Speculative Generality
      • Temporary Field
      • Message Chains
      • Middle Man
      • Inappropriate Intimacy
      • Alternative Classes with Different Interfaces
      • Incomplete Library Class
      • Data Class
      • Refused Bequest
      • Comments

      • Duplicate code: identical or very similar code exists in more than one location.
      • Large method: a method, function, or procedure that has grown too large.
      • Large class: a class that has grown too large, see God object.
      • Feature envy: a class that uses methods of another class excessively.
      • Inappropriate intimacy: a class that has dependencies on implementation details of another class.
      • Refused bequest: a class that overrides a method of a base class in such a way that the contract of the base class is not honored by derived class. See Liskov substitution principle.
      • Lazy class: a class that does too little.
      • Duplicated method: a method, function, or procedure that is very similar to another.
      • Contrived Complexity: forced usage of overly complicated design patterns where simpler design would suffice.
      Checkstyle, PMD and FindBugs for Java, to automatically check for certain kinds of code smells.

      Antipatterns In Software Development, Software Architecture, and Project Management

      A collection of bad practices from AntiPatterns: Refactoring Software, Architectures, and Projects in CrisisAntiPatterns: Refactoring Software, Architectures, and Projects in Crisis. More detail is available here.

      Software Development Antipatterns
      • The Blob
      • Continuous Obsolescence
      • Lava Flow
      • Ambiguous Viewpoint
      • Functional Decomposition:
      • Poltergeists
      • Boat Anchor
      • Golden Hammer
      • Dead End
      • Spaghetti Code
      • Input Kludge
      • Walking through a Minefield
      • Cut-and-Paste Programming
      • Mushroom Management
      Software Architecture Antipatterns
      • Autogenerated Stovepipe
      • Stovepipe Enterprise
      • Jumble
      • Stovepipe System
      • Cover Your Assets:
      • Vendor Lock-In
      • Wolf Ticket
      • Architecture by Implication
      • Warm Bodies
      • Design by Committee
      • Swiss Army Knife
      • Reinvent the Wheel
      • The Grand Old Duke of York
      Project Management Antipatterns
      • Blowhard Jamboree
      • Analysis Paralysis
      • Viewgraph Engineering
      • Death by Planning
      • Fear of Success
      • Corncob
      • Intellectual Violence
      • Irrational Management
      • Project Mismanagement
      • Throw It over the Wall
      • Fire Drill
      • The Feud
      • E-mail Is Dangerous