Artwork

Content provided by iteration podcast, John Jacob, and JP Sio - Web Developers. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by iteration podcast, John Jacob, and JP Sio - Web Developers or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ppacc.player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

A System for Growth

46:29
 
Share
 

Manage episode 217251196 series 1900125
Content provided by iteration podcast, John Jacob, and JP Sio - Web Developers. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by iteration podcast, John Jacob, and JP Sio - Web Developers or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ppacc.player.fm/legal.

A weekly podcast about programming, development, and design through the lens of amazing books, chapter-by-chapter.

A System for Growth

Dealing with complicated models

  • John: How / Why do they grow? Needs change:

  • John: All the different use cases for a user

John:

"When you need to implement password recovery, and do not have a clear, single place to put the logic, it will still find its way into your code. It will spread itself across existing classes, usually making those classes harder to read and use.”

Example problem: Want to send a welcome email when a user is created via a public form but not when an admin creates a user via a backend interface

  • Fat models == missing classes
  • don't actively look for an AR class, look for new classes to contain new logic

A home for interaction specific code

Core models should only have the absolute minimum to exist:

  • set of validations to enforce data integrity
  • definitions for associations (belongs_to, has_many)
  • universally useful convenience methods to find or manipulate records (scopes)

Core models should NOT have these things: (these things belong in multiple, interaction-specific form models)

  • virtual attributes that don't map 1:1 with db

  • callbacks to fire for a particular screen or use case (i.e. form signup)

  • we want the perks of AR models with AR. solution: inheritance

    class User::AsSignUp < User
    validates :password, presence: true, confirmation: true
    after_create :send_welcome_email

    private def send_welcome_email; end 

    end

  • John: Note the "AsSignup" pattern - "AsFacebookAuth"

Extracting service objects (lol)

  • probably a good indicator of a service object is when you find yourself using class methods. i.e. def self.something
  • John: Didn’t we just move code around? - "what used to be a monolithic blob of intertwined logic is now separated into multiple, loosely coupled components.” Better maintainability, testing, and reuse.

Organizing large codebases with namespaces

class Invoice < ActiveRecord::Base has_many :items end class Item < ActiveRecord::Base belongs_to:invoice end 

Why not just:

class Invoice::Item < ActiveRecord::Base belongs_to:invoice end 

and move the file to: app/models/invoice/item.rb

  • core domain at a glance
  • John: Pros- Namespaces have an inherent hierarchy - Encourages more objects, clear path for them.

Taming Stylesheets

The recommendations are a lot like BEM - A front-end development methodology - learn more at: http://getbem.com/

  • John - Recommend a Readme.md for front-end specific code, or having front end specific guides in the readme.
  • John - Have a process, and document your process. Have a system.
  • John - Contractor (Frank Hock) - Recommended a very specific folder structure:

Abstracts (Sizing, Boarders, Spacing)Base (Grid, Colors, images, Typography)Components (Buttons, Cards, Alerts)Page Specific CSS

Picks:

  continue reading

78 episodes

Artwork

A System for Growth

iteration

113 subscribers

published

iconShare
 
Manage episode 217251196 series 1900125
Content provided by iteration podcast, John Jacob, and JP Sio - Web Developers. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by iteration podcast, John Jacob, and JP Sio - Web Developers or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ppacc.player.fm/legal.

A weekly podcast about programming, development, and design through the lens of amazing books, chapter-by-chapter.

A System for Growth

Dealing with complicated models

  • John: How / Why do they grow? Needs change:

  • John: All the different use cases for a user

John:

"When you need to implement password recovery, and do not have a clear, single place to put the logic, it will still find its way into your code. It will spread itself across existing classes, usually making those classes harder to read and use.”

Example problem: Want to send a welcome email when a user is created via a public form but not when an admin creates a user via a backend interface

  • Fat models == missing classes
  • don't actively look for an AR class, look for new classes to contain new logic

A home for interaction specific code

Core models should only have the absolute minimum to exist:

  • set of validations to enforce data integrity
  • definitions for associations (belongs_to, has_many)
  • universally useful convenience methods to find or manipulate records (scopes)

Core models should NOT have these things: (these things belong in multiple, interaction-specific form models)

  • virtual attributes that don't map 1:1 with db

  • callbacks to fire for a particular screen or use case (i.e. form signup)

  • we want the perks of AR models with AR. solution: inheritance

    class User::AsSignUp < User
    validates :password, presence: true, confirmation: true
    after_create :send_welcome_email

    private def send_welcome_email; end 

    end

  • John: Note the "AsSignup" pattern - "AsFacebookAuth"

Extracting service objects (lol)

  • probably a good indicator of a service object is when you find yourself using class methods. i.e. def self.something
  • John: Didn’t we just move code around? - "what used to be a monolithic blob of intertwined logic is now separated into multiple, loosely coupled components.” Better maintainability, testing, and reuse.

Organizing large codebases with namespaces

class Invoice < ActiveRecord::Base has_many :items end class Item < ActiveRecord::Base belongs_to:invoice end 

Why not just:

class Invoice::Item < ActiveRecord::Base belongs_to:invoice end 

and move the file to: app/models/invoice/item.rb

  • core domain at a glance
  • John: Pros- Namespaces have an inherent hierarchy - Encourages more objects, clear path for them.

Taming Stylesheets

The recommendations are a lot like BEM - A front-end development methodology - learn more at: http://getbem.com/

  • John - Recommend a Readme.md for front-end specific code, or having front end specific guides in the readme.
  • John - Have a process, and document your process. Have a system.
  • John - Contractor (Frank Hock) - Recommended a very specific folder structure:

Abstracts (Sizing, Boarders, Spacing)Base (Grid, Colors, images, Typography)Components (Buttons, Cards, Alerts)Page Specific CSS

Picks:

  continue reading

78 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide

Copyright 2025 | Privacy Policy | Terms of Service | | Copyright
Listen to this show while you explore
Play