thePlebDev / Clicker

A Twitch Android client built with moderators in mind. Join the subreddit to voice your ideas, questions and concerns. Link to app on Google Play store below. Next update is 2024-07-29
https://play.google.com/store/apps/details?id=elliott.software.clicker
6 stars 2 forks source link

The Rules for PBI architecture #552

Open thePlebDev opened 8 months ago

thePlebDev commented 8 months ago

Proposed change

Why is this important

Anything top level can be used anywhere in the code base How to determine where the composable should go: 1) if it uses the slot layout then it is a builder 2) if it does not use the slot layout and is only used inside of this declaration then it is a part 3) parts are allowed to be made up of multiple parts 4) if it does not contain a slot layout and is used elsewhere in the code base, then it goes at the top level and is considered an implementation

Additional context

thePlebDev commented 7 months ago

5) If there are multiple parts inside another part. Consider making it a builder

thePlebDev commented 7 months ago

6) Builders are NOT`allowed inside of builders

thePlebDev commented 7 months ago
thePlebDev commented 7 months ago
thePlebDev commented 7 months ago

9) When refactoring first break things down into parts. This will be easier to see where the waste is(unwanted code or code reuses)

thePlebDev commented 7 months ago

10) breaking down into parts means try to organize by Column, Row, Box and other organizational composable

thePlebDev commented 7 months ago

11) If a composable contains multiple parts it is a good candidate for a builder

thePlebDev commented 7 months ago

12) once everything has been broken down into parts. Then look for builders and finally implementations

thePlebDev commented 7 months ago

13) Implementations can contain other implementations

thePlebDev commented 7 months ago

14) one level of nesting with builders, consider merging the two together. Multiple levels of nested builders, consider making taking the multiple nested builders into their own implementation

thePlebDev commented 7 months ago

Documentation rules:

1) When documenting implementations, the first sentence should tell the user when builder they are using: - MainScaffoldComponent is the implementation of [Builder.ScaffoldBuilder].

2) Builders should declare where they are being used in the first sentence: - ScaffoldBuilder is used inside of [MainScaffoldComponent].

3) Since parts can contain multiple parts, the first sentence should contain a declaration of how many parts it contains: - CustomTopBar contains 0 other parts or - CustomTopBar contains 2 other parts, [CustomText] and [CustomRow] - If their are multiple instances of the same part. They may be counted as 1 part

4) Using KDoc, the proper way to write the documentation when a part contains multiple parts is this:

 /**
         * - LiveChannelRowItem contains 2 extra parts:
         * 1) [ImageWithViewCount]
         * 2) [StreamTitleWithInfo]
 * */

5) Using KDoc, the top level object should start with a declaration of how many implementations it has, followed by a short description:

/**
 * - Contains 1 implementation:
 * 1) [MainScaffoldComponent]
 *
 * - ScaffoldComponents represents all the UI composables that create the scaffold experience inside the HomeView.
 *
 *
 * */

6) The encompassing object declaration can be named anything. However the inner object declarations should always be called: Builders and Parts:

object MainChat{

 private object Builders{
    // all the builders

     }
 private object Parts{
    // all the Parts

     }

}
thePlebDev commented 7 months ago
- instead do this:

/**

thePlebDev commented 7 months ago

15) There are now 2 types of implementations:

1) normal top level implementations. These are the normal top level implementations that can be used anywhere in the code base.

2) private top level implementation These type of implementations are private and are only used inside of other implementations. These are only used when implementations are getting so complex that a nested implementation is needed. In my code base you can see an example with the EnhancedChatSettingsBox composable function

thePlebDev commented 7 months ago

16) parts can not use Builders. If you have a part that uses a builder, it is now a private top level implementation

thePlebDev commented 7 months ago

17)Builders should not have the world Builder in their name.

thePlebDev commented 7 months ago

Downside of implementing this style guide:

1) really is a pain when trying to update something that currently exists. You need to update the code, then the documentation and depending on what you are updating, you will also have to update where this code is used.

thePlebDev commented 7 months ago

18) PBI and sometimes C architecture

thePlebDev commented 7 months ago

19) Combined parts before single parts


- This rule dictates that in the file, `AutoModRow` should be placed before `DropDownRow`
thePlebDev commented 7 months ago

20) Constants Should live inside the ViewModel