Thursday, February 28, 2019

Industry Practices and Tools - II

1. Discuss the importance of maintaining the quality of the code, explaining the different aspects of the code quality.

Readability :

Its means that the code is easy to follow, logically. Standards of indentation and formatting are followed, so that the code and its structure are clearly visible. Variables are named meaningfully. So its can be readable to others.

Testability :

It can be easily testable when the the code followed the coding standards. Thats means it will be very easy to do the unit testing for testers.

Efficiency :

Its directly related to the speed and performance of running the software. The quality of the software can be evaluated with the efficiency of the code used. Every lines of the code should be considered here.

Maintainability :

Code that is easy to add new features, modify existing features or fix bug with a minimum of effort without the risk of affecting other related modules. Softwares always need new features or bug fixes. So the written code must be easy to understand.

We can Maintain the Quality of the Codes following below steps..

  • Good Naming of variable.
  • Good Naming of Classes and Methods.
  • Use proper indentation and formatting style.
  • Good technical documentation
  • Write appropriate comments.


2. Explain different approaches and measurements used to measure the quality of code  


Weighted Micro Function Points

Its a modern software sizing algorithm. Its produces more accurate results than traditional software sizing methodologies. WMFP uses a pareses to understand the source code breaking it down into micro functions and derive several codes complexity and volume metrics. Its also supports new methodologies like Agile.

Halstead's Complexity Measures.

It was introduced to measure measure software complexity. Halstead's Metrics depends upon the actual implementation of program and its measures, which are computed directly from the operators and operands form source code, in static manner. It allows to evaluate testing time, vocabulary, size, difficulty, errors, efforts for c,C++/Java source code. 


He defines various indicators to check complexity of module.
ParameterMeaning
n1Number of unique operators
n2Number of unique operands
N1Number of total occurrence of operators
N2Number of total occurrence of operands

the following result is seen in Metric Report:
MetricMeaningMathematical Representation
nVocabularyn1 + n2
NSizeN1 + N2
VVolumeLength * Log2 Vocabulary
DDifficulty(n1/2) * (N1/n2)
EEffortsDifficulty * Volume
BErrorsVolume / 3000
TTesting timeTime = Efforts / S, where S=18 seconds.

Cyclomatic Complexity

Cyclomatic complexity is a source code complexity measurement that is being correlated to a number of coding errors. It is calculated by developing a Control Flow Graph of the code that measures the number of linearly-independent paths through a program module.


Lower the Program's cyclomatic complexity, lower the risk to modify and easier to understand. It can be represented using the below formula:
Cyclomatic complexity = E - N + 2*P 
where,
  E = number of edges in the flow graph.
  N = number of nodes in the flow graph.
  P = number of nodes that have exit points

Lines of Code

Source lines of code (SLOC), also known as lines of code (LOC), is a software metric used to measure the size of a computer program by counting the number of lines in the text of the program's source code.



3. Identify and compare some available tools to maintain the code quality.

Code Stricker :
  • Support for traditional documents review
  • It can be integrated with Bugzilla, ClearCase, CVS, etc.
  • Codestriker tool is licensed under GPL
Review Board :
  • Review Board can be integrated with ClearCase, Perforce, CVS, Plastic, etc
  • The code is syntax highlighted which makes it more readable
  • Support for pre-commit reviews and post-commit reviews
Codacy :
  • Helps you to identify new issues early in the process and prevent your product from being affected
  • Get visibility into the quality of your code
  • Seamlessly integrated into your workflow
  • The self-hosted solution, packed with first class security on your servers
Download link: https://www.codacy.com/
SonarQube :
  • Branch Analysis
  • Analyze pull requests
  • Enforce quality gate
  • Focus on the leak

4. Discuss the need for dependency/package management tools in software development? 
Its make sure the same version of dependencies you used in dev environment is what is being used in production. No unexpected behaviours

To make keeping your dependencies updated with latest patch, release or major version very easy.


5. Explain the role of dependency/package management tools in software development 

A Dependency is an external standalone program module (library) that can be as small as a single file or as large as a collection of files and folders organized into packages that performs a specific task.

when you declare a dependency in your config file — e.g. composer.json, the manager will goto the repository to fetch the dependency that match the exact criteria you have set in the config file and make it available in your execution environment for use.

 Maven for Java , Composer for PHP , bpm for NodeJS


6. Compare and contrast different dependency/package management tools used in industry

Maven - Java
Composer - PHP
npm - NodeJS
Gradle - Android

Maven :
  • making the build process easy
  • Providing quality build system
  • Providing uniform build system
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features
Composer :
  • You have a project that depends on a number of libraries 
  • Some of those libraries depend on other libraries.
  • Its Find out which version of packages need to be installed.


7. What is a build tool? Indicate the significance of using a build tool in large scale software development, distinguishing it from small scale software development 

Build tools are programs that automate the creation of executable applications from source code(eg. .apk for android app). Building incorporates compiling,linking and packaging the code into a usable or executable form.
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:
  1. Downloading dependencies.
  2. Compiling source code into binary code.
  3. Packaging that binary code.
  4. Running tests.
  5. Deployment to production systems

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

8. Explain the role of build automation in build tools indicating the need for build automation  

Build-automation utilities allow the automation of simple, repeatable tasks. When using the tool, it will calculate how to reach the goal by executing tasks in the correct, specific order and running each task.

Server types
  • On-demand automation such as a user running a script at the command line
  • Scheduled automation such as a continuous integration server running a nightly build
  • Triggered automation such as a continuous integration server running a build on every commit to a version-control system.

Build automation 
  • A necessary pre-condition for continuous integration and continuous testing 
  • Accelerate the compile and link processing 
  • Eliminate redundant tasks 
  • Minimize "bad builds" 
  • Documentation – has the history of builds and releases in order to investigate issues 
  • Save time and money, and improve product quality


9. Compare and contrast different build tools used in industry

  1. For java - Ant,Maven,Gradle.
  2. For .NET framework - NAnt
  3. c# - MsBuild.


10. Explain the build life cycle, using an example (java, .net, etc…) 

A Maven build lifecycle is a sequence of phases we need to go through in order to finishing building the software

  1. validate the project
  2. compile the sources
  3. run those against the tests
  4. package the binaries (e.g. jar)
  5. run integration tests against that package
  6. verify the package
  7. install the verifed package to the local repository
  8. deploy the installed package in a specified environment


11. What is Maven, a dependency/package management tool or a build tool or something more?

Maven is a build automation tool used primarily for Java projects. Maven addresses two aspects of building software: first, it describes how software is built, and second, it describes its dependencies


12. Discuss how Maven uses conventions over configurations, explaining Maven’s approach to manage the configurations


Maven uses Convention over 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. 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.


13. Discuss the terms build phases, build life cycle, build profile, and build goal in Maven 


Goals are executed in phases which help determine the order goals get executed in. The best understanding of this is to look at the default Maven lifecycle bindings which shows which goals get run in which phases by default. The compile phase goals will always be executed before the test phase goals which will always be executed before the package phase goals and so on.

Part of the confusion is exacerbated by the fact that when you execute maven you can specify a goal or a phase. If you specify a phase then maven will run all phases up to the phase you specified in order (e.g. if you specify package it will first run through the compile phase and then the test phase and finally the package phase) and for each phase it will run all goals attached to that phase.


14. Discuss with examples, how Maven manages dependency/packages and build life cycle 


A Build Lifecycle is a well-defined sequence of phases, which define the order in which the goals are to be executed. Here phase represents a stage in life cycle. As an example, a typical Maven Build Lifecycle consists of the following sequence of phases.
PhaseHandlesDescription
prepare-resourcesresource copyingResource copying can be customized in this phase.
validateValidating the informationValidates if the project is correct and if all necessary information is available.
compilecompilationSource code compilation is done in this phase.
TestTestingTests the compiled source code suitable for testing framework.
packagepackagingThis phase creates the JAR/WAR package as mentioned in the packaging in POM.xml.
installinstallationThis phase installs the package in local/remote maven repository.
DeployDeployingCopies the final package to the remote repository.

There are always pre and post phases to register goals, which must run prior to, or after a particular phase.
Maven has the following three standard lifecycles −
  • clean
  • default(or build)
  • site


15. Identify and discuss some other contemporary tools and practices widely used in the software industry 

Docker

Docker provides a software containerization platform that enables you to package your application or software in a filesystem. This container could be moved and executed anywhere. You will find everything that you need to run: code, system libraries, etc. This means that the software will be running the same and will not depend on its environment.

Slack

Slack is an amazing app that we all use for team communication. It’s great because we can use it basically everywhere (it has a native app for iOS and Android), and since we’ve been using it, we have reduced emails sent internally. We have a team for each department but also have one for the whole company! It’s quite practical: you’ve got “channels” that you create for whatever you want (projects, teams, topics, etc.) and you can easily navigate between channels.

Git

Git is an open-source version control system for software projects. When a developer is working on something, he or she has to regularly do changes to the code until he or she reaches the last version.

GitHub

GitHub is a Git repository hosting web. It’s a type of dropbox for software projects where you can find code. When uploading your project, you have the choice of making it public or private. It’s a great place to network and meet like-minded people, share projects, discover others, etc. The community is huge and the project base even bigger

Jenkins

Jenkins is an open-source automation server, more specifically, a Continuous Integration server. You can picture this software development tools as if it were the middleman between your code and your build server because it regularly looks for changes on your server and once they're found, it sends them to the build server. 


Additional :

Maven Interview Questions & Answers Here

No comments:

Post a Comment