Logo

dev-resources.site

for different kinds of informations.

Proposal for a framework.json file in Angular applications

Published at
5/14/2023
Categories
angular
readability
bestpractice
Author
arboricum
Categories
3 categories in total
angular
open
readability
open
bestpractice
open
Author
9 person written this
arboricum
open
Proposal for a framework.json file in Angular applications

Proposal for a framework.json file in Angular applications

It is really hard sometime to figure out all the relationships between angular components, expecially when they become many.
You'd want to know with a first glance who's child of who, or parent of who, or where a component is being used.
Maybe you'd wish to know which service or directive is being shared.
I found nothing on the web helping with this problem.
So I figured out a framework file where the app framework is actually displayed.
This will be a JSON file, with the following features:

  • Component: camel case string -> components' class name -> it's an object where the properties are:
    • @string (see below), in the following order: services (@Ser), directives (@Dir), models (@Model), modules (@/Mod), @router-outlet;
    • other components;
    • the object will be an empty one if there are no children or @string.
  • @string properties key-value ->
    • @Ser is an array of services, elements are the services' class names (camel case);
    • @Dir is an array of directives, elements are the directives' class names (camel case);
    • @Model is an array of models, elements are the models' class names (camel case);
    • @/Mod is an array of modules, elements are the modules' selector names (exact match);
    • @router-outlet, is an object where the properties are components
  • same indentation -> siblings
  • different indentation -> lower is child of higher parent (or is displayed in router-outlet)

This is an instance of an example app:

{
    "AppComponent": {
        "HeaderComponent": {},
        "@router-outlet": {
            "RecipeComponent": {
                "@Ser": ["RecipeService"],
                "RecipeListComponent": {
                    "@Ser": ["RecipeService"],
                    "@Model": ["Recipe"],
                    "RecipeItemComponent": {
                        "@Model": ["Recipe"]
                    }
                },
                "@router-outlet": {
                    "RecipeStartComponent": {},
                    "RecipeEditComponent": {
                        "@Ser": ["RecipeService"]
                    },
                    "RecipeDetailComponent": {
                        "@Ser": ["RecipeService"],
                        "@Dir": ["DropdownDirective"],
                        "@Model": ["Recipe"]
                    }
                }
            },
            "ShoppingListComponent": {
                "@Ser": ["ShoppingListService"],
                "@Model": ["Ingredient"],
                "ShoppingEditComponent": {
                    "@Ser": ["ShoppingListService"],
                    "@Model": ["Ingredient"]
                }
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

It could be a best practice to provide the app with such a file, which I would nest inside the app folder.
Suggestions and comments are welcome.
GitHub: [https://github.com/Arboricum/Improvements-for-Angular]

bestpractice Article's
30 articles in total
Favicon
From Bi-weekly to Every 5 Minutes: Modern Continuous Deployment Strategies
Favicon
Notación Big O - Python
Favicon
Docker Advance Part 2: Docker Logging
Favicon
Client Extension no Liferay
Favicon
Dockerfile Best Practices: How to Create Efficient Containers
Favicon
Microservice Best Practices: Scale your java microservices using virtual threads & async programming
Favicon
Design Patterns for C
Favicon
Mastering React Hooks: Best Practices for Efficient and Maintainable Code
Favicon
Why You Should End Your Source Files With a New Line
Favicon
Puppet best practice
Favicon
@Nullable et @NonNull
Favicon
Component best practice question.
Favicon
How to Use CodeWhisperer to Identify Issues and Use Suggestions to Improve Code Security in your IDE
Favicon
Mastering React: Best Practices for Cleaner and More Efficient Code
Favicon
AWS Well-Architected Review in Action
Favicon
Improving Code Quality in Java: Best Practices and Examples
Favicon
Mastering JavaScript Event Handling for Enhanced Frontend Functionality
Favicon
TIL: Best Practices for Handling Secret Keys in Sinatra - The Do's and Don'ts
Favicon
Enhancing Website Accessibility: A Guide for Supporting Users with Disabilities
Favicon
Proposal for a framework.json file in Angular applications
Favicon
Part 3: Component Structure - Building Reusable and Maintainable Components in React!
Favicon
Using useReducer and Redux Toolkit Together: A Powerful Combination for State Management
Favicon
Separation of concerns in React and React Native.
Favicon
REST-API Design Best Practices
Favicon
Flags In Programming
Favicon
10 Essential Best Practices for Writing High-Quality C++ Source Code
Favicon
Avoiding code duplication in styled components
Favicon
Es mala práctica renderizar JSX en React Hook?
Favicon
ReactJS Best Practices
Favicon
Why you should adopt Makefile in all of your projects

Featured ones: