Settling the File Structure Debate
– muhammedsari.me - submitted by Muhammed Sari
Group by type or context / process? One of these methods will crush your project's growth. Find out which!
Read more [muhammedsari.me]
Posts tagged with code structure
– muhammedsari.me - submitted by Muhammed Sari
Group by type or context / process? One of these methods will crush your project's growth. Find out which!
Read more [muhammedsari.me]
– hakanaktas.com.tr - submitted by Hakan
A pragmatic approach to avoiding early optimizations
Read more [hakanaktas.com.tr]
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
– medium.com - submitted by CODE AXION
I have described where to put your scopes if your model is cluttered with 10 + scopes
Read more [medium.com]
Anna Filina shares how she goes about organizing small functions.
Read more [afilina.com]
It's funny how from the outside, IT is often seen as an exact science. When starting as a developer, I often heard people say: "Oh, you're in IT, so you must be good at mathematics". I never understood why someone who is supposedly good at mathematics is the right person to fix a printer.
When you have some experience building applications, you know that IT is not an exact science. There are multiple valid solutions to a problem. Take five developers and ask them what the best way to set up a blog is. You'll likely get five different answers. Each suggestion will have its own set of tradeoffs.
I don't necessarly agree with every detail in this post, but it's very interesting to see how others structure larger projects.
In this article, I would like to show you an alternative way to organize your Laravel directory structure. I think the default structure is fine for the most projects. But when it comes down to larger projects I was looking for a different structure.
Read more [stefanbauer.me]
In this blog post, I'd like to highlight two tips to make controllers in Laravel feel much lighter.
In an older but still relevant article on the Clean Coder Blog, Uncle Bob argues that the structure of your tests should not necessarly reflect the structure of your code.
The structure of the tests must not reflect the structure of the production code, because that much coupling makes the system fragile and obstructs refactoring. Rather, the structure of the tests must be independently designed so as to minimize the coupling to the production code.
Read more [blog.cleancoder.com]
In a new post to his site Mathieu Napoli makes the case for organising your code based on it's function rather than it's type.
We recently discussed 2 topics seemingly unrelated with my colleagues at Wizaplace: how to organize code? How to organize teams? ... Organizing code into domain modules is not a silver bullet but it forces to better understand the problem we are solving and better structure our code.
http://mnapoli.fr/organizing-code-into-domain-modules/
Alain Schlesser wrote an article on how to manage exceptions in a large codebase.
I seem to constantly work on improving my habits regarding the use of exceptions. I think it is an area that I haven’t yet fully explored, and it is very difficult to find anything more than very basic explanations and tutorials online. While the consensus is to use exceptions, there is very little information on how to structure and manage them in a larger codebase. The larger and more complex your projects become, the more important it is to start with a proper structure to avoid expensive refactoring later on.
https://www.alainschlesser.com/structuring-php-exceptions/
In my opinion a good exception message in most cases contains three things:
Named constructors for exceptions are the perfect place to build up such a message. Want to learn more? Ross Tuck wrote a good blog post on the subject too.
Frank de Jonge wrote an article on how to structure to your functions to avoid the duplication of cleanup code. Spoiler: use finally.
Cleaning up after yourself can be a tedious task. For example, closing file handlers after using them needs to be done. A programmer's life isn't all about the happy path. When things go pear-shaped you might end up duplicating cleanup code throughout your code. This is horrible, let's explore an alternative.
https://blog.frankdejonge.nl/finally-file-streams-and-deferred-execution-in-php/
That defer keyword from Go looks super nice.
Organizing code is a core skill for software developers and as with all skills the most effective way to improve is to reflect on your previous choices and the fallout from them. There are a wide array of different strategies for organizing code and learning to recognize both the useful and the dangerous ones is very important.https://medium.com/@msandin/strategies-for-organizing-code-2c9d690b6f33#.3fcr619nk
At Spatie we use a homegrown Laravel template called Blender. It's being used on nearly all our projects. When starting with a greenfield project we take a copy of Blender and make project specific changes in that copy. We built it because we want maximum flexibility and don't want to be hampered by…