How we can achieve writing reusable and modular code in an Enterprise code. What are the basics to get started
How we can achieve writing reusable and modular code
154 Views Asked by VIKRAM SINGH CHOUHAN At
1
There are 1 best solutions below
Related Questions in REUSABILITY
- Automated Testing (Watir): Retrieving data and implementing into your test?
- timeout behaviour of httpClient in C#
- Is my understanding of abstraction correct?
- Is my way of reusing methods in JUnit tests bad?
- Add an asp code into another asp
- A simple way in WPF MVVM to reuse property method?
- Objective-C : Design tall xib over view and add to storyboard with scrollview
- Reusing a List View in iOS using MVVM
- Android multi project app structure
- Hooking into component
- Reuse HTML in the same page
- Java code reuse via method inheritance
- Reusing ASP.NET code in multiple pages
- What is a good/elegant way to handle conditional layout rendering with React Router?
- How to abstract Symfony 3 Entity logic?
Related Questions in MAINTAINABILITY
- Use GUI displayed results of SQL query vs new queries?
- Use Gradle function from other gradle file
- Prototype Pattern causes code repetition between "actual object" and "prototype"
- Generalizing work orders
- Criteria when using libraries - use Library's data type VS create my own type?
- Add reminder/tooltip/comment to show logical connection between 2 or more chunks of code
- Best practices for Django model lookup
- Reduce complexity, increase maintainability of multiple If-Else statements?
- Can anyone tell me why the maintainability index is only 40 for this code?
- Are enums less maintainable than public static final constants?
- Manage javascript for different type of users with PHP
- Javascript Code Structure
- Can't suppress CA1502
- What are the drawbacks of using a method which calls a delegate for every row in SqlDataReader?
- Add an attribute or create a new level in the XML hierarchy?
Related Questions in CODE-STANDARDS
- Best practice: returning multiple values
- Parenthesis placing after function
- How to check node.js code to code standards
- Correct way to reset counter in COBOL
- PSR-2 CodeSniffer standard for eclipse plugin PHP_CodeSniffer
- Google CodeStyle for Eclipse formatter shows version warning
- how to assure my implementation is in standard form (avoid bad coding)?
- Difference between dynamic boolean expression variable and boolean function
- jQuery best practices in case of $('document').ready
- How do I modify Eclipse code formatting?
- How to customize Eclipse's text editor code formatting
- Which PHP SPL Exception should you throw if a class doesn't exist
- How to organize controller class and action method?
- Format code to align with its own subsection clause
- How to format algebric code for readability
Related Questions in TESTABILITY
- Combining testable code with static method dispatch in swift
- Creating testable code
- Patterns for making c++ code easy to test
- What is the impact on testability for an associations passed as parameters to a class?
- Testable C application using posix threads
- Can I write any meaningful unit test in this scenario?
- stability test of ARDL model in R
- How we can achieve writing reusable and modular code
- Node.js: exporting class/prototype vs. instance
- whats wrong with a simple IOC container class?
- Are there exceptions to no code in view model?
- Correct design of classes built for testability using constructor injection
- Console.Writeline in class method. Better Design
- Testing fails to import sub dependency - @testable import SubModule - Use of undeclared type 'InternalSubModuleType'
- What is the correct way here to modify/refactor product code to support integration testing?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Writing modular code is an art of programming.
In Enterprise products, writing reusable code is a key to make your product reliable, testable and maintainable for long run. Modular and reusable code sits at the very heart of any standard product.
Let's take an example to understand how we can convert and existing code into more modular and reusable code.
Let say there exist a method/logic in the product which take an 1-D array of positive integers as input and evaluate the sum of all the elements.
This method actually evaluates the total transaction amount of a user in a given year. Consider that this was the initial business requirement and hence code has been written in such a fashion.
Now, let's say a new business requirement has come, which wants to evaluate the user transactions of a the first half of the year. How you are going to achieve it? Maybe writing one more method which can evaluate for first half of the year. Correct. Let see how that method looks like.
Cool we have done it. :) But can it be done in any other way, or may be a better way. Let see.
We can actually write a more generic/reusable method which can give the sum of transactions for a given period. Something like this
Now we can call this reusable method for both of the existing requirement.
And even any future requirements, lets say for the month of January, we need to simply call same method like this
Why we are looking for better way? may be to accommodate future requirements and reducing line of code.
What we achieved:
Thanks!