When we propose to solve problems in programming we always go directly to the computer and start writing code without first having analyzed the problem. That is what most of the programmers do.
Or well sometimes we are analyzing it and directly we are writing the code and well in some cases this practice works, of course When the problems are simple or when you are an experienced programmer.
Sometimes we think that by doing things directly we will save more time, but in reality, it is not like that, many of the time that a problem has been programmed directly without having done a previous analysis, is double or triple than if we had previously done an analysis, usually many mistakes are made, which in the long run we lose time.
A good habit of programmers is to carry a methodology to solve a problem, no matter how minimal it may be. That is why this time we are going to see some steps that we must follow to solve a programming problem and basically the idea is to make it a habit every time we go to a program.
- Previous Analysis Of The Problem
At this stage, it must be defined and clear what the program has to do together with the tasks it must perform to carry out the solution, what data do I need to carry out the tasks, what format the input data should have, where it comes from.
The input data, how that data is obtained, how the data interacts with each other to obtain the result, it is very important to be clear about what the result you want to obtain will be, nor to leave aside the restrictions that may exist when processing the data. As in the case of bootstrap templates, you should be well aware of how the problem analysis cycle works.
In the same way, all the scenarios that may occur must be analyzed since a change of scenario can change the final result of the program, it is always worth asking yourself and asking: what if this happens? What behavior the program would take.
To clarify doubts, you should ask for formats (ways of presenting the data or from where the data is obtained when done manually), formulas, make examples, and verify the results.
Basically, at this point or phase, all the requirements and specifications of the problem must be collected.
This point should be one of the most important and critical in troubleshooting since a bad analysis leads to bad design and later to a bad result.
Personally, it does not matter how long you take in this stage, the idea is that everything is clear, the first time it may take you a lot but as you practice it you will gain experience and if you take it as a habit in the next few times you will do it even faster.
- Algorithm Design
Once we are clear about the problem, after having defined all the inputs and outputs that the program will have, as well as the tasks to be performed, it is time to design the algorithm and that it will go according to all the previous specifications and later it will be implemented in a programming language to be executed by the computer.
The algorithm can be done in any way: Pseudocode or Flow Diagram, the main idea is that it should be understandable, and not only by the one who designed it but by anyone.
Something important about this design is that it is understandable for the programmer who is going to implement it.
- Coding And Development Environment Setup
This stage consists of transcribing or adapting the algorithm to a programming language, all the steps designed in the algorithm will have to be adapted with sentences and syntax of the language itself.
Checking for errors, organizing the code, and commenting on it are good practices that make programs more readable and facilitate debugging.
Before coding, you must have the work environment configured: IDEs, libraries, Frameworks (although I do not recommend the latter if you are starting to program, it is better to learn the most basic things, the fundamentals, everything by hand first and then the frameworks) and then pass the algorithm to the programming language.
- Compilation And Testing
The compilation phase will detect errors at compilation, execution, and logical times, and in the case of Java, one or more bytecode files will be generated that will be executed by the computer.
In this phase, it is also necessary to test a large amount of data to find and correct possible errors.
- Documentation And Maintenance
Finally, you must have documentation of all the steps until you reach the solution of the problem, sometimes this phase is a bit tedious but it is also very important since many times changes occur over time and these are done in some cases by other programmers different from the ones who created it (that even when you go to modify yourself, you don’t remember what the hell towards that code, it happened to me), and when a program is poor in the documentation, this modification process is totally complex.
Let’s Get To The Point, Let’s Solve A Problem Applying The Previous Steps
- Previous Analysis Of The Problem: Define What The Program Should Do
For this example I have taken a simple and real requirement, it is a small problem of a bank entity, the business manager of this entity needs a report (obviously the report must be in the banking system) in which the percentage of delinquency is shown (or delinquency index) for each of the agencies that the entity has.
There are several lines of credit offered by the entity, for example, Consumer, Microcredits, Commercial and Real Estate, to consider an overdue credit the maximum number of days for each line is taken into account, after this number of days the credit is considered past due.
Bear in mind that for each line of credit there is a different number of maximum days before considering the credit as past due.
The purpose of this report will allow the Business Manager to evaluate the delinquency and make decisions regarding the credits provided by the bank.
We Get The Detailed Requirement:
- Calculate the delinquency rate by the agency and consolidated for all agencies
Data To Understand The Problem:
NPL ratio or percentage is the quotient of total overdue loan balances and total loan balances. Let suppose if you want to solve problem related to marketing you can consult SEO services in Abu Dhabi for better results.
To Calculate The Delinquency Rate, The Following Formula Is Considered:
% NPL Overdue Portfolio/Total Portfolio
Overdue Portfolio=Overdue Consumer Portfolio+Overdue Microcredit Portfolio+Overdue Commercial Credit Portfolio+Overdue Real Estate Loan Portfolio
Total Portfolio=Balance of Consumer Credit Debt+Balance of Microcredit Debt+Balance of Commercial Credit Debt+Balance of Real Estate Credit Debt
The lines of credit and the maximum days for each one are shown below.
Expired Portfolio Of Consumer Credits
- For the calculation of the past due consumer loan portfolio, the debit balance of all overdue operations over 15 days is considered (this is from the 16th onwards)
Expired Portfolio Of Microcredits
- To calculate the overdue microcredit portfolio, the debit balance of all overdue operations over 15 days is considered (this is from the 16th onwards)
Expired Portfolio Of Commercial Credits
- For the calculation of the overdue commercial credit portfolio, the debt balance of all overdue operations over 30 days is considered (this is from day 31 onwards)
Overdue Portfolio Real Estate Credits
- To calculate the overdue portfolio of real estate credit, the debt balance of all overdue operations over 60 days is considered (this is from day 61 onwards)
- Algorithm Design
So far we have defined the problem and we have the information that is needed to solve it, now we need to take the necessary actions to solve it, these actions that follow a sequence of steps is called an algorithm, in this phase we can find several ways to solve the problem. We will try to use the most efficient way, this phase does not have an established format since it depends a lot on the logic of each developer, to the same problem several programmers can give different solutions.
At first, we could use any solution, since the purpose is to obtain the result, but as we have experienced it is worth looking for the most efficient solution.
A tip for designing a complex algorithm is to try to break down the problem into smaller sub-problems and divide them into even smaller chunks until reaching a level that is easier to solve. This method is technically known as top-down or modular design.
As I mentioned, the algorithm design is not unique, and we could try to do it in different ways.
In general, a solution could be the following:
- Obtain data by agency, credit line, and then by overdue credits according to the maximum days (Consumption and Microcredit> 15 days, Commercial> 30 days, Real Estate> 60 days) for each credit line.
- Store the balance of the overdue portfolio for that line of credit (Result step 1).
- Repeat steps 1 and 2 for all credit lines (Consumer, Microcredits, Commercial, Real Estate) for the same agency.
- Add the balances of all the credit lines obtained.
- Add the balances of all the loans by the agency to obtain the total portfolio.
- Obtain the delinquency index by the agency with the results obtained in points 4 and 5, according to the formula: % NPL = Overdue Portfolio / Total Portfolio
- Present in a report the name of the agency, the total portfolio, the past due portfolio, and the delinquency rate.
- Repeat steps 1 to 7 for each agency.
- To obtain the consolidated delinquency rate, we will add the overdue portfolio for each agency and the same with the total portfolio, and use the formula from point 6
So far we have solved the problem, although we could refine the algorithm, for example, assigning the results to variables, use control structures in algorithmic language, the idea is to make it simple and clear for any programmer so that it is easy to implement and let him take care of variables and control statements in the next step
As I mentioned there is no standard for the design and it may be that in other cases it is necessary to make diagrams or make pseudocode, that will go according to the complexity of the problem, but in short, the important thing is not to make more diagrams or more pseudocode, but instead, the important thing is that the algorithm is clear for its implementation
A technique to design algorithms when you are starting out and you do not have much experience, is to first do the steps in a general way and from there refine or polish it until you reach the optimal version, perfection and efficiency are achieved with practice, That is why the only way to improve in this phase is to practice and practice.
I was forgetting something, maybe at this point prototypes of screens are also designed with which the user will interact.
- Setting Up The Development Environment For Coding, Compiling, And Testing
The next thing is to configure the IDE, load the necessary libraries, reuse code that you may have from other projects, configure a Framework if it is used.
And later pass the design of the algorithm to the programming language, also in this case the screens are implemented, the syntax is verified, tests are carried out on the coding by the programmer and the program is debugged.
- Documentation
Finally, we need to generate documentation of how the application works so that the user can handle it functionalities, this is known as a manual, technical manual, the idea is that the user does not have problems with the use of software and programmers to make changes.
Well, as you can see, there are some things that I have omitted, such as coding and manuals, I would also have liked to show more formats, likewise, the algorithm could be refined more, but well a little for time reasons it was not possible, but in If the idea is that you learn the essentials from there you with your own problems you can polish them more.
Finally, emphasize that this is a good practice to start programming to have a good habit, but remember that to do it professionally and in programming teams and with projects, software development methodologies are usually used, which will also be another topic.
Add Comment