Unify Data Layer at Software Projects
<h1>Hello,<br />
Let’s start our article with some questions.</h1>
<p>…</p>
<ol>
<li>How many models <strong>(Holding data only without any logic)</strong> at your main working project right now? <strong>100</strong> or <strong>1000</strong> or <strong>10000 </strong>or even<strong> 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 <strong>redundant/duplicated</strong> models at your project?</li>
</ol>
<blockquote>
<p>So, let’s make it clear…</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 “<strong>Unify Data Layer at Software Projects”</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>