Pages

Thursday, September 27, 2012

5 Common Automized Software Quality Metrics (with Pros & Cons)





1. Source Lines of Code (SLOC)
Counting lines of code is probably the most simple method. It mostly indicates the scale of the software and gives an input for project growth and planning. For example, if we get SLOC count once a month, we may sketch a graph of project growth. Of course this is not reliable due to refactoring and design phases but may give a viewpoint.

SLOC may be counted as Source Logical Line of Code (SLLOC) for better info. Logical code lines does not include empty lines, one char brackets and comment lines. You can easily calculate SLLOC using tools like Metrics

Line of code should not be used for evaluating developer performance. This may cause duplicate, unmaintainable and unprofessional code.


2. Bugs per code_section/module/time_period
Bug tracking is essential for better testing and faster maintainability. If bugs are tracked, bugs per code section, module or specific time period (day, week, month etc.) may be calculated easily by reporting tools (e.g. Mantis). If this value is obtained, bug causes may be noticed and intervened early.

Bug count may be used as one of the inputs of evaluating developer performance, but attention must be paid. If it is most important evaluation method, software developers and testers may become enemies. In a productive company, all employees must be coherent with each other.

For better evaluation, bugs may be classified as low, medium, high etc. for weighting, because their importance and resolving costs are not the same. 


3. Code Coverage
Code coverage states the degree to which the source code of a program has been tested. Automaticity of code coverage calculation is a plus. There are so many tools which perform that operation (e.g. Cobertura). 

Code coverage does not represent the whole quality of unit tests, but may give some info about test coverage. It may be used as a software metric together with a few other test metrics. Also unit test codes, integration test scenarios and results should be reviewed frequently.

4. Design/Development Constraints
There are so many design constraints and principles for software development. Some of them are:
  • Class/method length,
  • Number of methods/attributes in a class,
  • Method/constructor parameter counts,
  • Magical number, string usage in code files,
  • Comment lines percentage etc.
These are important for code maintainability and readability. Development teams may choose a few (or all) of those metrics and follow them with automized tools (like maven pmd plugin). This will raise the quality of produced software.


5. Cyclomatic Complexity
We separated cyclomatic complexity from other design/development constraints because its concept is a bit different. Cyclomatic complexity is about the detailed implementation and code execution. It also may be calculated automatically with tools like pmd.

It is calculated as "the count of the number of linearly independent paths through a source code section". For example, if there are a path diagram of a source code section as below:



Cyclomatic Complexity = E(edges) - N(nodes) + 2P (exit nodes)
So, Cyc.Cmp. = 8 - 7 + 2*1 = 3

You can also see that there are 3 different paths from leftmost node to rightmost node. This value can be calculated especially for methods, using the whole method source as the execution path. Some upper limit numbers (6, 8 or 10 etc.) may be defined according to the project type.

Only one metric does not detect the quality of your whole project or solve everything. If you use more metrics, you will have more viewpoints about the quality of your project. 


Monday, June 25, 2012

20 Subjects Every Software Engineer Should Know





Here are the most important subjects for software engineering, with brief explanations:

1.Object oriented analysis & design: For better maintainability, reusability and faster development,  the most well accepted approach, shortly OOAD and its SOLID principals are very important for software engineering.

2.Software quality factors: Software engineering depends on some very important quality factors. Understanding and applying them is crucial.

3.Data structures & algorithms: Basic data structures like array, list, stack, tree, map, set etc. and useful algorithms are vital for software development. Their logical structure should be known.

4Big-O notation: Big-O notation indicates the performance of an algorithm/code section. Understanding it is very important for comparing performances. 

5.UML notation: UML is the universal and complete language for software design & analysis. If there is lack of UML in a development process, it feels there is no engineering.

6.Software processes and metrics: Software enginnering is not a random process. It requires a high level of systematic and some numbers to monitor those techniques. So, processes and metrics are essential.

7.Design patterns: Design patterns are standard and most effective solutions for specific problems. If you don't want to reinvent the wheel, you should learn them.

8.Operating systems basics: Learning OS basics is very important because all applications runs on it. By learning it, we can have better vision, viewpoints and performance for our applications.

9.Computer organization basics: All applications including OS requires a hardware for physical interaction. So, learning computer organization basics is vital again for better vision, viewpoints and performance.

10.Network basics: Network is related with computer organization, OS and the whole information transfer process. In any case we will face it while software development. So, it is important to learn network basics.

11.Requirement analysis: Requirement analysis is the starting point and one of the most important parts of software engineering. Performing it correctly and practically needs experience but it is very essential.

12.Software testing: Testing is another important part of software engineering. Unit testing, its best practices and techniques like black box, white box, mocking, TDD, integration testing etc. are subjects which must be known.

13.Dependency management: Library (JAR, DLL etc.) management, and widely known tools (Maven, Ant,  Ivy etc.) are essential for large projects. Otherwise, antipatterns like Jar Hell are inevitable.

14.Continuous integration: Continuous integration brings easiness and automaticity for testing large modules, components and also performs auto-versioning. Its aim and tools (like Hudson etc.) should be known.

15.ORM (Object relational mapping): ORM and its widely known implementation Hibernate framework is an important technique for mapping objects into database tables. It reduces code length and maintenance time.

16.DI (Dependency Injection): DI or IoC (Inversion of Control) and its widely known implementation Spring framework makes life easy for object creation and lifetime management on big enterprise applications.

17.Version controlling systems: VCS tools (SVN, TFS, CVS etc.) are very important by saving so much time for collaborative works and versioning. Their logical viewpoint and standard cammands should be known. 

18.Internationalization (i18n): i18n by extracting strings into external files is the best way of supporting multiple languages in our applications. Its practices on different IDEs and technologies must be known.

19.Architectural patterns: Understanding architectural design patterns (like MVC, MVP, MVVM etc.) is essential for producing a maintainable, clean, extendable and testable source code.

20.Writing clean code: Working code is not enough, it must be readable and maintainable also. So, code formatting and readable code development techniques are needed to be known and applied.

Wednesday, June 13, 2012

5 Common Antipatterns in Software Project Management






Overplanning/analysis/meetings:
Some companies or project teams falls into error of spending time for the project planning & analysis & meetings much more than needed. Planning detail is not needed to be "complete" in each phase. This may be a serious bottleneck for projects. Like planning, analysis is also not needed to be complete at the beginning, except waterfall projects. As we know, waterfall is not such an efficient software process/methodology, until there is not a contract obligation about that. Planning and analysis should be "as required" and have flexibility points. Also, meeting duration and intervals are very important about this concept. Only required meetings with required staff and with shortest possible duration should be performed. Otherwise a huge time loss and unnecessary brain fatigue on staff will be inevitable.

Project mismanagement:
Most employees like working in a relaxed environment and company. But on the other hand, if their work is not monitored and controlled, they are also not satisfied. Monitoring and controlling is required for non-managers because they need to be directed (they are not employer and they don't have to make every important decision), leaded (code reviews, trainings etc. are important for self development, also scheduling is important for efficiency) and appreciated (high performance and skills needs good feedbacks, at least a few good words). And they also want to know that they are doing an important job and they are part of that organization. So, an ethical staff will also require to be managed and controlled "as required".

Wrong choices of staff motivation techniques:
Job satisfaction (passion for the job concept, learning and self-development), human interactions (between employers and employee) and income (convenient with job type and sector averages) are very important for staff motivation. Job details, development plans, income and midterm income possibilities must be explained before starting job and if everything is OK, they must not be changed after starting job. Beyond the technical and economical issues, communication is the most important concept in teamworks. IT staff is not a kind of people that can be motivated using hard wording, hierarchical and forbidding working style. They should feel confidence and comfort. After that, performance will be OK. If these things cause inactivity on staff, those staff is not right choice and an action must be taken as soon as possible.

Wrong selection of metrics and evaluation methods:
Metrics are important tools for monitoring software development process and they can provide some different viewpoints. For example, widely used "line of code" (especially logical line of code LLOC) metric may be used for "monitoring the growth of project by code size". If you attempt to evaluate developer efficieny using LOC, this will be a huge mistake because short and efficient code, design patterns etc. will be punished. Also copy paste programming, unreadable code etc. will be rewarded. E.g. cyclometic complexity, scheduling compliance, bug count are better methods. But best of all is determining right metrics according to the project type and team member properties.

Documentation strategy mistakes
Documentation is very important for software projects. Planning, analysis, design, development and testing phases need "required" level of documentation. Even for some fastest agile processes like SCRUM, documentation is needed. Main purpose of documentation is making life easier for developers and users. For example use case definitions are important on development phase, complex problem solutions are important on maintainance phase or on employee shifts, diagrams are important for understanding concepts fast and clearly. However documentation should not consume a very important percentage of whole project schedule. Generally it may be %5-10.