Importance of Code quality, Package management, Build tools and Additional tools
Importance of maintaining the quality of the code
·
Easy
to read and understand to users or client, what have done in the code/program.
So it’s really useful when maintain and extend the code.
·
If
the code is in good quality, number of bugs are reduced. Less bugs mean the
software is smoothly working.
·
Efficiency: It
is always good to make sure you keep your code efficient. Efficiency of code
covers a variety of things such as the reliability and speed being two
examples.
·
Portability: Portability
in terms of good quality code is when we can code across different systems and
operating systems. A program should be portable because if a program was
developed for a client and it could only be used on particular devices or
operating systems then it would have an affect on the way that the
client/company uses the system. E.g.
JAVA
How to measure the quality of code?
We can measure the quality by using these aspects.
·
Weighted
Micro Function points
·
Halstead
Complexity Measures
·
Cyclomatic
Complexity
·
Lines
of code
·
Lines
of code per code method
Available tools to maintain the code quality
1.
SonarQube
·
Open
source platform, launched in 2007.
·
Designed
to support global continuous improvement strategy on code quality within the
company.
·
This
can be used as a shared central system for quality management.
·
This
tool supports a wide variety of languages like Java, C/C++, C#, PHP, Flex,
Groovy, JavaScript, python and PL/SQL.
·
Sonar
offers fully automated analyses tools and integrates well with Maven, Ant,
Gradle.
·
It
doesn’t show only what’s wrong. It also offers quality management tools to help
you put it right.
·
There
are code quality metrics that show your progress and whether you’re getting
better or worse.
2.
PMD
·
static
code analysis tool that helps with the automated detection of a plethora of
potential bugs and non-optimized or unsafe code.
·
It
examines the Java source code while looking for potential problems, which
includes dead code, suboptimal code, duplicate code, overcomplicated
expressions, and possible bugs.
3.
FindBugs
·
An
open-source Java code quality tool sharing some features with Check style and
PMD while having a different focus.
·
The
functioning of the FindBugs isn’t concerned with the formatting or coding
standards and has marginal interests in the best practices.
·
This
is instrumented to detect a variety of hard-to-find coding mistakes like thread
synchronization problems, infinite recursive loops, null pointer dereferences,
misuse of API methods and more.
4.
CSS LINT
·
This
is help to find problems in CSS code.
·
Basically
checking the syntax and applying a set of rules to the code that look for
problematic patterns or signs of inefficiency
Dependency management tools
Dependency Management is used to pull all the dependency
information into a common POM file, simplifying the references in the child POM
file.
It becomes useful when you have multiple attributes that you don’t want to retype in under multiple children projects. Finally, dependency Management can be used to define a standard version of an artifact to use across multiple projects.
It becomes useful when you have multiple attributes that you don’t want to retype in under multiple children projects. Finally, dependency Management can be used to define a standard version of an artifact to use across multiple projects.
Managing your dependencies manually in any programming
language is a huge pain. This is why in most programming languages today you
will find that they all have some implementation of a dependency management
system or sometimes a package manger.
Here are some tools.
·
Composer
This dependency manager for PHP lets you create a composer.json
file in your project root,
run a single command, and all your dependencies are downloaded ready to use.
This deal with packages or libraries, but manage them on a
per-project basis, install in a directory inside your project.
·
NuGet
NuGet is the package manager for the Microsoft development
platform including .NET. The NuGet client tools provide the ability to produce
and consume packages. The NuGet Gallery is the central package repository used
by all package authors and consumers.
When we install NuGet, it copies the library files to your
solution and automatically update project.
·
Nanny
Nanny is a dependency management tool for managing
dependencies between your projects. Unlike tools like Maven, Nanny can be used
for arbitrary dependencies and is easy to use.
Nanny makes it easy to create dependencies and manage
dependency versions.
·
Maven
It provides quality project information. Make the build
process easy. Allow transparent migration to new features.
Build Tools
Build tools are programs that automate the
creation of executable applications from source code. (e.g. Apk for android
app). Building incorporates compiling, linking and packaging the code into a
usable or executable form. In small projects, developers will often manually
invoke the build process.
Basically
build automation is the act of scripting or automating a wide variety of tasks
that software developers do in their day-to-day activities like:
- Downloading dependencies.
- Compiling source code into binary code.
- Packaging that binary code.
- Running tests.
- Deployment to production systems.
This is not
practical for larger projects, where it is very hard to keep track of what
needs to be built, in what sequence and what dependencies there are in the
building process. Using an automation tool allows the build process to be more
consistent.
In small
projects, developers will often manually invoke the build process. This is not
practical for larger projects, where it is very hard to keep track of what
needs to be built, in what sequence and what dependencies there are in the
building process. Using an automation tool allows the build process to be more
consistent.
Build automation is a process of automating the creation
of a software build and associated process including compiling computer source
code into binary code, packaging binary code and running automated tests. It is
a necessary pre- condition for continuous integration and continuous testing.
This helps
to accelerate the compile and link processing.
This eliminate redundant tasks and helps to reduce “bad builds”. And
also save time and money and improve quality of the product.
Here are few
build tools used in industry.
·
Python(pybuilder)
PyBuilder is a
software build tool written in pure Python which mainly targets Python
applications. It is based on the concept of dependency based programming but
also comes along with powerful plugin mechanism that allows the construction of
build life cycles similar to those known from other famous build tools like Apache Maven.
Open source.
·
Gradle
Gradle is a project
automation tool that builds upon the concepts of Apache Ant and Apache Maven
and introduces a Groovy-based domain-specific language instead of the XML form used by Apache Maven for
declaring the project configuration. Gradle uses a directed
acyclic graph ("DAG") to determine the order in which tasks can be
run. Scale out development with elegant, blazing-fast builds. From compile
avoidance to advanced caching and beyond, then team can deliver continuously.
This designed for
multi-project builds can be grow larger. t supports incremental builds by
intelligently determining which parts of the build tree are up to date
·
ANT
This originated from the
Apache Tomcat project in early 2000. t is similar to Make but is implemented
using the Java language,
requires the Java platform, and is best suited to building Java projects.
ANT uses XML to describe the code build process and dependencies.
But makes uses the makefile format. ANT is an open source project.
·
Buildr
This is an open source
build system mainly intended to build Java. It gives developer a full- brown
scripting language, while build scripts, which are usually missing in XML-based
building environments such as ANT or Maven.
·
Maven
This also used
primarily for Java projects. Maven uses Conventionover Configuration, which
means developers are not required to create build process themselves. Developers
do not have to mention each and every configuration detail. Maven provides
sensible default behavior for projects
Maven Lifecycle
Maven is
based around the central concept of a build lifecycle. The process for building
and distributing a particular artifact (project) is can clearly define. only
necessary to learn a small set of commands to build any Maven project, and the
POM will ensure they get the results they desired.
There are
different built-in build lifecycle.
- Default lifecycle
·
validate: Validate
the project is correct and all necessary information is available.
·
compile: Compile
the source code of the project.
·
test: Test the
compiled source code using a suitable unit testing framework These tests should
not require the code be packaged or deployed.
·
package: Take
the compiled code and package it in its distributable format, such as a JAR.
·
integration-test: Process and deploy the package if necessary into an environment where
integration tests can be run.
·
verify: Run
any checks to verify the package is valid and meets quality criteria.
·
install: Install
the package into the local repository, for use as a dependency in other
projects locally.
·
deploy: Done
in an integration or release environment, copies the final package to the
remote repository for sharing with other developers and projects.
To do these things need to call the last build phase to be
executed, for these example is deploy. Because if we call a build phase, it
will execute not only that build phase, but also every build phase prior to the
called build phase.
- Maven clean install
Clean action processing in each module before running install
action for each module. Mvn clean
install clears any compiled files we have and confirm that we are compiling
correctly each module from scratch.
Clean is a separate lifecycle.
Therefore, it’s not called by default.
A target folder holds Maven-generated temporary files and
artifacts. There are times when the target folder becomes huge or when certain
files that have been cached need to be cleaned out of the folder. The clean
goal accomplishes exactly that, as it attempts to delete the target folder and
all its contents.
Here is the code.
$ mvn clean install
So now you have an idea about dependency and build tools. So
Let’s find the Maven is a dependency or a build tool.
Maven is a dependency management tool and a build automation
tool, mostly used for java applications.
Maven continues to use XML file in a manageable way. Maven relies on
conventions and provides predefined commands(goals).
Maven allows us to focus on what our build should do, and
gives us the framework to do it. Another positive aspect of Maven was that it
provided built-in support for dependency management.
Maven’s configuration file, containing build and dependency
management instructions, is by convention called pom.xml. Additionally,
Maven also prescribes strict project structure, while Ant provides flexibility
there as well.
Maven can be considered a plugin execution framework, since
all work is done by plugins. Maven supports a wide range of available plugins, and each of
them can be additionally configured.
And also Maven has made big improvement regarding making
application’s build processes easier and more standardized.
Convention over Configuration
Maven uses Convention over Configuration, So
developers are not required to create build process themselves.
Developers do not have to mention each and every
configuration detail. Maven provides sensible default behavior for projects.
When a Maven project is created, Maven creates default project structure.
Developer is only required to place files accordingly and he/she need not to
define any configuration in pom.xml.
As an example, following table shows the default
values for project source code files, resource files and other configurations.
Assuming, ${basedir} denotes the project location
Item
|
Default
|
source code
|
${basedir}/src/main/java
|
Resources
|
${basedir}/src/main/resources
|
Tests
|
${basedir}/src/test
|
Complied byte code
|
${basedir}/target
|
distributable JAR
|
${basedir}/target/classes
|
In order to build the project, Maven provides
developers with options to mention life-cycle goals and project dependencies
(that rely on Maven plugin capabilities and on its default conventions). Much
of the project management and build related tasks are maintained by Maven
plugins.
Developers can build any given Maven project without
the need to understand how the individual plugins work. We will discuss Maven
Plugins in detail in the later chapters.
Other contempory tools and practces used in industry
•Continuous Integration
This is a
development practice need to developers to integrate code into a shared repository
several time per day. An automated problem detecting system everything checks
and verified before share to repository. Developers can detect errors and fixed
easily.
•Configuration Management
CM system is used
to keep track of an organization’s hardware, software and real information. This
includes software versions and updates installed on organization’s computer
system. This involves logging the network addresses belonging to the hardware
devices used.
•Test automation
•Issue/bug tracking tools
•Agile methodologies, DevOps
DevOps is a software
development method which focuses on communication, integration, and
collaboration among IT professionals to enables rapid deployment of products.
This allows deploying code to production faster and in an automated way.
Agile Methodology involves
continuous iteration of development and testing in the SDLC process. This
software development method emphasizes on iterative, incremental, and
evolutionary development. Agile development process breaks the product into
smaller pieces and integrates them for final testing.
Comments
Post a Comment