Unify Data Layer at Software Projects

<h1>Hello,<br /> Let&rsquo;s start our article with some questions.</h1> <p>&hellip;</p> <ol> <li>How many models&nbsp;<strong>(Holding data only without any logic)</strong>&nbsp;at your main working project right now?&nbsp;<strong>100</strong>&nbsp;or&nbsp;<strong>1000</strong>&nbsp;or&nbsp;<strong>10000&nbsp;</strong>or even<strong>&nbsp;100000</strong>?</li> <li>Is the same quantity of models at other platforms? (If you are iOS Developer, is it the same at Back-End and Android and Front-End?)</li> <li>Are you have many&nbsp;<strong>redundant/duplicated</strong>&nbsp;models at your project?</li> </ol> <blockquote> <p>So, let&rsquo;s make it clear&hellip;</p> </blockquote> <p>First, the quantity of models is not important if everything has usage and it is clear.</p> <blockquote> <p>Our article is about &ldquo;<strong>Unify Data Layer at Software Projects&rdquo;</strong></p> </blockquote> <p>And, of course you are suffering from having a lot of models have same variables with just small changes and you make them to confirm APIs response at different routes.</p> <p>For example:-</p> <p>You have endpoint to get List of users and response is list of user as following:</p> <pre> public struct User: Codable { private let id: Int? private let name: String? private let phone: String? private let email: String? }</pre> <p>And, you have another endpoint to get single user and response is user as following</p> <pre> public struct User: Codable { private let id: Int? private let name: String? private let phone: String? private let email: String? private let country: Country? private let currency: Currency? private let wallet: Wallet? }</pre> <p>What do you think , you should create the response of two endpoints as one model or create two models to each response?</p> <p><a href="https://medium.com/@m7amdelbana/unify-data-layer-at-software-projects-f1880ca482ea">Visit Now</a></p>
Tags: Data Software