Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Knowing all the advantages TDD offers. It is possible to apply strictly and all the time in all kind of projects (large projects)? Or is it nothing more than an exaggeration?
One has to consider both advantages and disadvantages, the main disadvantage being the time cost. You typically need to write 1 line of unit testing for every line of code. TDD makes no sense if your functionality is very likely to change a lot in the future, because you will have to rewrite all tests all the time. For example a case of an early prototype, where you mostly want to just test some idea rather than making a super stable application.
Another case is if you want to support the change in your application. Then TDD will give you benefits in the long term. Is it possible to apply strictly? Certainly it is possible, but not easy, as it is typical that business people try to reduce short-term costs and disallow using TDD fully. TDD creates short-term costs (writing the tests) in hope to reduce long-term costs (loosing quality due to sudden bugs or extensive manual tests).
Sometimes it is not possible to use TDD.
For example, when writing classes in c++ to display GUI components, it makes no sense to unit test everything. If using MVP design pattern, models in MVP trio should be unit tested, but not the views.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm working in company with a big system with a messy code structure. I want to work with the right standards like polymorphism and design patterns.
But the code is such a mess and needs to be heavily refactored to do that. Also my current company gives me tasks, and if I have would heavily refactor, that will open many bugs in the system as it's not unit tested, of course.
What do you think? Should I work on the tasks on this bad structure to finish the work? Or tell them that we need rebuild many things (also they won't find a difference as the features already work now).
I think you need to start off with some unit tests.
Whilst doing the tasks you have been assigned, you could write some tests to test the code you are about to change, then you can refactor it.
Now you can start to write the code for your task, test-first.
If the code that is already there works, then refactoring is the best option. If it doesn't work, then a rewrite becomes possible.
Well...you need to work on multiple aspects.
First, learn best practices to write clean code (if you haven't yet) and request your team members the same. There are many useful books and online resources available for the same.
Second, do not expect that the situation will change overnight. Adopt "Boy scout rule" - it will gradually improve the code quality.
Third, start building your corpus of unit tests. Slowly, testable code will emerge out of the sea of untestable monolith.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
This is supposed be an open question but I would like the answer to focus more on code design aspects.
To help narrow the scope of the answer:
How do you decide if a class should be a concrete class or an interface that is mocked when it's not so obvious.
What's your experience of allocating roles and responsibilities.
To what dependency depth do you typically go to.
How much of the already perceived target design influences the tdd process.
What's you experiences of making a tdd driven implementation fit within pre-existing code.
any other design consideration.
Thanks!
Uncle bob defined the three laws of TDD:
You are not allowed to write any production code unless it is to make a failing unit test pass.
You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
Following the classic Red-Green-Refactor cycle, remember about the four rules of simple design defined by Kent Beck. Apply them during the refactor phase. The code must (in priority order):
Run all the tests
Contain no duplicate code
Express all the ideas the author wants to express
Minimize classes and methods
The 0th law of TDD:
Break the TDD process whenever it is too tedious, motherfucker!
How do you know that TDD is too tedious? When you regularly write tests in
5 minutes, and it suddendly takes you more than one 8 hour shift to write
those tests for that part, which calls 3rd party something, then it is too
tedious. Forget unit tests and test it manually from time to time. The goal
is to have 95% covered, not 100%.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have been trying to learn the basics of software engineering principles, but I have come across a question that I cant find enough detail on to answer, any help would be appreciated:
For each of the process models (i.e. waterfall, incremental, prototyping
and spiral), how does the model handle a significant change in requirements late in the
development?
Thanks in advance.
I think this question can be simplified - broadly speaking there are two types of software development life cycle:
Iterative (or agile) methodologies like Scrum and Extreme Programming.
Sequential (or "big design upfront") methodologies like waterfall.
The iterative methodologies rely on the experiential feedback from within the project. In Scrum, the sprint review provides guidance concerning what can be achieved in the next sprint and the review of the product backlog can promote the latest requirements to the top of the priority list. In iterative methodology, the evaluation phase of the increment can feed into the planning for the next iteration.
These two examples show a clear point at which the methodologies can adapt and react to new requirements.
There are of course some specific details beyond this broad stroke explanation. For example, a Scrum team wouldn't actually change scope until the end of the sprint - unless the sprint was completely abandoned. As a result there could be a small delay before new requirements could begin implementation.
With the more traditional methodologies such as Waterfall, accommodating adaptation is more difficult because you are constrained by the current phase of the series of phases. To adapt requirements it's likely going to involve non-optimal design and implementation because of the nature of the change being bolted on. If the changes in the requirements were significant enough the entire development may be abandoned and restarted. At least with the agile methodologies you will have already developed, or in fact shipped, some increment of business value.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
4 years ago, I've built a webapp which is still used by some friends. the problem with that app, is that now it has a huge database, and it loads very slow. I know that is just my fault, mysql queries are mixted all over the places(even in the layout generation time).
ATM I know some about OO. I'll like to use this knowledge in my old app, but I don't know how to do it without rewriting all the from the beginning. Using MVC for my app, is very difficult at this moment.
If you were in my place, or if you will had the task to improve the speed of my old app, how you will do it? Do you have any tips for me? Any working scenarios?
It all depends on context. The best would be to change the entire application, introducing best practices and standards at once. But perhaps would be better to adopt an evolutionary approach:
1- Identify the major bottlenecks in the application using a profiling tool or load test.
2 - Estimate the effort required to refactoring each item.
3 - Identify the pages for which performance is more sensitive to the end user.
4 - Based on the information identified create a task list and set the priority of each item.
Attack one prolem at a time, making small increments. Always trying to spend 80% of your time solving the 20% more critical problems.
Hard to give specific advice without a specific question, but here are some general optimization/organization techniques:
Profile to find hot spots in your code
you mention mysql queries being slow to load, try to optimize them
possibly move data base access to stored procedures to help modularize your code
look for repeated code and try to move it to objects one piece at a time
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
How do you start planning a fairly large project? Do you immediately start writing up the major classes and break it down further and further? Do you sit down and draw out some UML?
I'm designing my first large project (well, large compared to the other ones) and I'm looking for ideas.
I suggest reading about agile methodology and scrum.
Large Projects would be beneficial when used Agile scrum methodology.
Agile methods divides your projects into smaller sprints giving one the time to prioritize the main features to be concentrated & completed.
Continuous interaction with client means less ambiguity, more real value. The client would see live ideas before final. So more improvising at very early stage with ample of time to make it better.
Bug fixing process gets speedy. Less the bugs, more efficient the Project!
By using time-boxed, fixed schedule Sprints of 1-4 weeks, new features are delivered quickly and frequently, with a high level of predictability. This also provides the opportunity to release or beta test the software earlier than planned if there is sufficient business value.
Improves Quality. By breaking down the project into manageable units, the project team can focus on high-quality development, testing, and collaboration. Also, by producing frequent builds and conducting testing and reviews during each iteration, quality is improved by finding and fixing defects quickly and identifying expectation mismatches early.