9
votes
Is it okay to use Dependency injection only because of unit testing?
It is absolutely okay to use a programming method only to support proper testing. Test suites are just as important as business code - the fact that you don't ship them to the customer is not ...
4
votes
Accepted
How to refactor parallel inheritance tree?
This sounds like a better approach would be to implement a list of business rules with validity date limits, section applicability, ordering key. Then for every section, you execute the applicable ...
3
votes
Languages with PHP-like traits?
In PHP, "traits" are a way to reuse code in classes, providing a mechanism for horizontal code reuse. "Traits" allow you to define methods that can be used in multiple classes ...
3
votes
Why does PHP have int and float data types?
Efficiency. All computers can do integer math extremely efficiently, as in billions of operations per second, and most (these days) can do the same with floating point.
String math? Not so much.
PHP ...
2
votes
Is it code smell to make an abstract child class override a parent method which only calls its own abstract method
I'm going to go with "yes"
It seems obvious from the need to completely replace the functionality in multiple classes that NonWalkingMammal should be the base class, then WalkingMammal can ...
2
votes
Best way to protect action links from CSRF
With the proper use of a cookie and a query string parameter, you can emulate what many CSRF mitigation strategies use. Before delving into securing cookies, this is what the process entails:
Set a ...
2
votes
Best way to protect action links from CSRF
You pretty much answered the question your self, just use a form with CSRF protection. A GET url is easier to abuse by malicious parties (through links and images etc.) but CSRF protection will work ...
2
votes
frontend server obtain data from backend server, or frontend server return page with javascript that obtain data from backend server?
The second approach has several benefits over the first one.
The work of adjusting the rendered page with the information from the back-end server is distributed to all the various client devices, ...
2
votes
What is the proper pattern for a singleton SETTINGS class load using composer?
The code you have shown actually doesn't follow the Singleton pattern, it instead uses a global constant to store configuration data. It doesn't prevent creation of multiple Settings instances, which ...
2
votes
Should I split backend into legacy and modern app to make the rewrite feasible?
What would the situation be if you did nothing - that is, neither split the codebase nor rewrote the whole, and just worked within the legacy framework?
It sounds like you don't have the resources for ...
1
vote
frontend server obtain data from backend server, or frontend server return page with javascript that obtain data from backend server?
If you're taking the second approach, then be aware that you should never trust code running on someone else's machine.
There are ways for a user to dynamically replace the javascripts on a web page ...
1
vote
Is it okay to use Dependency injection only because of unit testing?
I have a class that has dependencies that I know are not going to change.
No you don't. Even if you dedicate the rest of your life to making this prophecy come true, you still don't know. This is ...
1
vote
Organize and maintain a lot of cron jobs
I would suggest combining jobs that should be run on the same schedule (hourly, twice daily etc.) but should not run in parallel into shell scripts which execute them in sequence, so if one job runs a ...
1
vote
Organize and maintain a lot of cron jobs
I don't use the particular technologies mentioned, but a complicated system of scheduling can easily get out of hand.
Almost 30 distinct schedules (and growing) strikes me as far too much even for ...
1
vote
Is it code smell to make an abstract child class override a parent method which only calls its own abstract method
The whole point of abstract methods is that they must, in general, be defined by the implementing class. Your entire implementation is to call another method, which is...OK, though not great as a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
php × 2046object-oriented × 260
mysql × 197
design-patterns × 189
web-development × 139
mvc × 139
javascript × 107
design × 96
database × 77
laravel × 71
web-applications × 68
architecture × 56
java × 50
frameworks × 49
object-oriented-design × 48
security × 47
unit-testing × 45
api × 45
html × 45
programming-practices × 41
dependency-injection × 41
python × 37
ajax × 37
rest × 35
sql × 35