{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreictzom3poghx3mapaj45o2urylkynpheep5giocodnqwrzcpohrea",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mopkv6in57t2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreihziaxv3rmdvknkx5rbz2os2wwwqr5hy3zfcobzonm3nmp5dw5uwa"
},
"mimeType": "image/webp",
"size": 46064
},
"path": "/ali_hamza_589ec7b3eb6688d/day-48-of-leaning-mern-stack-123n",
"publishedAt": "2026-06-20T09:12:09.000Z",
"site": "https://dev.to",
"tags": [
"node",
"backend",
"express",
"javascript"
],
"textContent": "Hello Dev Community! 👋\n\nIt is officially **Day 48** of my unbroken full-stack engineering journey! Yesterday, I refactored my modular core patterns into MVC architecture. Today, I linked up a major functional extension inside the `/model` layer by introducing **JavaScript Classes (OOP)** to coordinate my local file operations and storage data patterns!\n\nInstead of writing loose object definitions, I stepped up my enterprise game by structuring a reusable class footprint that encapsulates data parameters and handles non-blocking file-system persistence asynchronously.\n\n## 🧠Key Learnings From Day 48 (OOP Modeling & File Systems)\n\nAs clearly shown in my development workspace layout within **\"Screenshot (116).png\"** , modeling data with dedicated classes shifts your core structural logic from simple scripts into highly scalable engines:\n\n### 1. The Model Data Blueprinter (`constructor`)\n\nI used the standard ES6 `class` framework inside `home.js` to structure an explicit data mold (`houseList`) with attributes tracking: `houseName`, `price`, `location`, `rating`, and `photoUrl`. This ensures every entry traveling through our server follows an identical structure.\n\n### 2. Streamlining Async Persistence (`save()`)\n\nRather than relying on globally declared floating arrays, my `.save()` blueprint method triggers an internal lookup to read existing data stacks asynchronously before safely using `fs.writeFile()` to serialize and flash mutated JSON rows into a local data asset (`homesdata.json`).\n\n### 3. Static Decoupled Fetchers (`static fetchAll()`)\n\nI mastered using `static` methods. Since reading a data grid requires pulling records without creating an instance of a single house first, making `fetchAll(callback)` static allows our controllers to tap the hard disk records straight from the class reference layout:\n\n\n javascript\n // A conceptual look at my file-reading design today\n static fetchAll(callback) {\n const filePath = path.join(rootDir, 'data', 'homesdata.json');\n fs.readFile(filePath, (err, data) => {\n if (err) {\n callback(JSON.parse(data));\n } else {\n console.log(err);\n }\n });\n }\n",
"title": "Day 48 of Leaning MERN Stack"
}