Swift: Why You Shouldn’t Use Default Implementations in Protocols

//  Session.swift

import RealmSwift

import Foundation

@objc public enum SessionType: Int {

    case workshop

    case meetup

    case breakfast

    case announcement

    case talk

    case lightningTalk

    case sponsoredDemo

    case coffeeBreak

    case lunch

    case officeHours

    case party

}

public class Session: Object {

    /** The type of content in this particular session */

    open dynamic var type: SessionType = .talk

    // many other class properties here

    /***************************************************/

    // VIEW DISPLAY LOGIC BELOW

    /** The main name of this session */

    public var formattedTitle: String? {

        switch self.type {

           // VERY LONG SWITCH STATEMENT

           // LOTS OF DISPLAY LOGIC

        }

    }

    /** A follow-up tagline for the session */

    public var formattedSubtitle: String? {

        switch self.type {

           // VERY LONG SWITCH STATEMENT

           // LOTS OF DISPLAY LOGIC

        }

    }

    /** What image, if any is available for this session */

    public var logoURL: URL {

        switch self.type {

           // VERY LONG SWITCH STATEMENT

           // LOTS OF DISPLAY LOGIC

        }

    }

    /** The location for where this session will occur */

    public var formattedLocation: String {

        switch self.type {

           // VERY LONG SWITCH STATEMENT

           // LOTS OF DISPLAY LOGIC

        }

    }

    /** A long-form description of the session */

    public var sessionDescription: String {

        switch self.type {

           // VERY LONG SWITCH STATEMENT

           // LOTS OF DISPLAY LOGIC

        }

    }

    /** Presentation Summary */

    public var presentationSummary: String {

        switch self.type {

         // VERY LONG SWITCH STATEMENT

         // LOTS OF DISPLAY LOGIC

        }

    }

  

   // YOU GET THE POINT

   // MORE METHODS HERE WITH A LOT OF SWITCH STATEMENTS

}

Share this post:

Be the first to comment

Leave a Reply

Your email address will not be published.


*