My Blog List

Showing posts with label object oriented programming. Show all posts
Showing posts with label object oriented programming. Show all posts

Monday, May 30, 2011

Study Terms: Interface Builder

Am currently working with the Neil Goldstein/Tony Bove book iPad Application Development for Dummies, Version 2. Some ideas to reinforce from today's reading.

(page 101)


* The View Controller Window is the table of contents for the nib file. It represents an instance of each object. Also it always contains two proxy objects.

Proxy Objects

What is a proxy object? I know that a proxy is a substitute for an object and that an objective-C class can be accessed through a proxy object. They are something I give directions to to assume control for me. I think that proxy objects create things on the fly as opposed to my hard-coding them. I'd like to increase my understanding of proxy objects, because I think it would help me to better understand some of the ways that the SDK works.

      * File's Owner
             * is the controller object
             * is responsible for contents of the nib file
             * (in this example) is the View Controller

      * First Responder
              * first entry in the apps dynamically constructed responder chain
              * is the object, with which, the user is currently interacting

(Regular) Objects (in book example p 101)

       * View
              an instance of the UIView class






Wednesday, May 25, 2011

Staying Tuned: Reflecting on Objective-C



I switched gears in my work on Objective-C, and stopped blogging because of that. I realized I needed to become more of an objective-oriented programmer in my thinking and stopped off to take a class in C++. Now I plan to return to my self-study of Objective-C.

I'll be working with some other books.

Stay Tuned.

Tuesday, November 2, 2010

Demonstrating Polymorphism OR TRAPPED IN TIME?

Version:1.0 StartHTML:0000000201 EndHTML:0000074336 StartFragment:0000002867 EndFragment:0000074300 SourceURL:file://localhost/Users/Laurel/Apps%20Learning/Journal%20TrappedInPolymorphicTime.doc
// TrappedInTime

Loading program into debugger…
Program loaded.
run
[Switching to process 7629]
Running…
    PERIOD PILOTS Staff Members are currently performing maintenance on this portal
Your trip is being routed to another time portal.
 Thank you for your patience
 ....    PERIOD PILOTS Maintenance Log for Tuesday, November 2, 2010

 Performing Maintenance on Time Portal of type: Bridge

Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Portal of type:  Canyon
Performing Maintenance on Time Port

* * * TASK CANCELLED BY PORTAL PILOT SUPERVISOR * * *



//  Or why Time Portal Constructors need to wear the right GLASSES  @ the computer
// I was so enchanted with the bug I created using an = instead of a < to control my loop, that I was determined to return
//       AFTER ALL
//  As we learn from reading history, great scientific discoveries are often made by mistake
//         OR
//  It's a feature not a bug

for(loopIndex =0; loopIndex < 2; loopIndex++)
  // for(loopIndex =0; loopIndex = 2; loopIndex++)



WHAT WE EXPECTED

This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
Loading program into debugger…
Program loaded.
run
[Switching to process 7588]
Running…
    PERIOD PILOTS Staff Members are currently performing maintenance on this portal
Your trip is being routed to another time portal.
 Thank you for your patience
 .... 
  PERIOD PILOTS Maintenance Log for Tuesday, November 2, 2010

 Performing Maintenance on Time Portal of type: Bridge

Performing Maintenance on Time Portal of type:  Canyon

....
  Maintenance Cycle of all Time Portals in this zone,
  completed properly on Tuesday, November 2, 2010

Debugger stopped.
Program exited with status value:0.



//  GettingWorkDoneInATimelyManner

//  Demonstrating polymorphism: Using the same code with different objects
//      the object that is used is determined at runtime when I pass a message

//based on example in Quick Start Objective C , Holzner, page 139
//

#include <stdio.h>

#include <Foundation/Foundation.h>

@interface Bridge : NSObject
-(void)  print;
@end

@implementation Bridge

-(void) print
{
    printf("Performing Maintenance on Time Portal of type: Bridge\n");
}

@end
//
@interface Canyon : NSObject
-(void)  print;
@end

@implementation Canyon

-(void) print
{
    printf("Performing Maintenance on Time Portal of type:  Canyon\n");
}

@end

int main (void) {
    printf ("\t PERIOD PILOTS Staff Members are currently performing maintenance on this portal\n");
    printf("Your trip is being routed to another time portal.\n Thank you for your patience\n");

    printf("\f.... \f  PERIOD PILOTS Maintenance Log for Tuesday, November 2, 2010\n ");
   
    Bridge *c1 =  [Bridge new]  ;
    Canyon *c2 =  [Canyon new]  ;
    id pointerToObject;
    int loopIndex;
   
    pointerToObject = c1;
   
 for(loopIndex =0; loopIndex < 2; loopIndex++)
    //  for(loopIndex =0; loopIndex = 2; loopIndex++)
    {
        [pointerToObject print];
        pointerToObject = c2;
       
    }
   
   
    printf("\f.... \f  Maintenance Cycle of all Time Portals in this zone, \f  completed properly on Tuesday, November 2, 2010\n ");

    return 0;
}



Tuesday, October 26, 2010

Reviewing Concepts: Portal Inheritance, Object Method

This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
Loading program into debugger…
Program loaded.
run
[Switching to process 45244]
Running…
Portal Pilots: Encountered a Time Portal
Portal Type is a Bridge

Debugger stopped.
Program exited with status value:0.

.....

#include <stdio.h>
#import <Foundation/Foundation.h>

// Portalinherit: Simple Portal Inheritance

//Based on: inheriting base-class methods QStart page 125

@interface Portal : NSObject

-(void) print;

@end

@implementation Portal
-(void) print
{
    printf("Portal Pilots: Encountered a Time Portal\n");  
}
@end

@interface Bridge : Portal

-(void) print2;

@end

@implementation Bridge
-(void) print2
{
    printf("Portal Type is a Bridge\n");  
}
@end

int main (void)
{
  
    // Instantiate the 'Bridge' class
    // create an object called 'bridge' that points to the Bridge instance
  
    Bridge *bridge = [Bridge new];
  
    // execute an object method (page 83)
    //  syntax is '[object object_method_name]'
  
    [bridge print];
    [bridge print2];
  
  
  
    return 0;
}

Friday, October 22, 2010

Reviewing Concepts: Identify Time Portals

Las Pilitas Time Portal
I’m finding it really useful to have worked my way down to this book, which lays out one simple concept after another. It helps me to focus on one thought at a time and how oop is different than being a structured programmer. I wonder what it will be like to go back to those other two books I used during the summer, with their much more complex examples, when I’m done with this one. It sure is tempting to jump ahead in time and find out! 

One thing I’ve found challenging learning Objective-C is knowing that I’m doing things that I’ll be unlearning later on. In this example, I know that naming each class as a particular Time Portal isn’t as cleanly object oriented as I’ll be later on. I wouldn’t setup a record in a database schema like this. Or even in an old-fashioned file-management system. These are really instances of the same class.

Now, when I say ‘instances of the same class’ am I thinking right? There’s where a background using database methodology sometimes trips me up. Like when I catch myself thinking than an object is a variable or a class is a record. They aren’t.

Come back to this later and see if I had this ‘instance’ business right or not.


……..
[Session started at 2010-10-20 09:27:32 -0700.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1469) (Wed May  5 04:36:56 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys001
Loading program into debugger…
Program loaded.
run
[Switching to process 333]
Running…
Located Portal at LasPilitasSLO.
Located Portal at MillbraeBARTStation.

Debugger stopped.
Program exited with status value:0.
 ...

#import <stdio.h>
#import <Foundation/NSObject.h>

// GUI NOTE It's SHIFT Command/Apple F to do a find & replace in XCode
//       Been trying to find global find & replace for awhile now!
//       Regular appleF just highlights all the occurances in the piece of code

// Locate and Identify Time Portals for Portal Pilots Service

// Based on ideas from Page 112 of Virtual Quickstart Guide Objective-C (Holzner)
// Multiple Object Types and use of 'id'type
//
// Create objects of two different class types
//    Place them in the same variable of type id

// NOTE ORDER of *multiple* INTERFACE & METHOD sections
//        I write the interface for one class then it's methods
//      I repeat this structure for the other class
//  

@interface LasPilitasSLO:NSObject
-(void) print;
@end

//METHODS for LasPilitasSLO

@implementation LasPilitasSLO
-(void) print
{
    printf("Located Portal at LasPilitasSLO.\n");
}

@end


@interface MillbraeBARTStation:NSObject
-(void) print;
@end

//METHODS for MillbraeBARTStation
@implementation MillbraeBARTStation
-(void) print
{
    printf("Located Portal at MillbraeBARTStation.\n");
}

@end

int main (void) {
    LasPilitasSLO *c1 = [LasPilitasSLO new];
    MillbraeBARTStation *c2 = [MillbraeBARTStation new];
    // Remember
    // Here I am declaring 'container' to be of type id
    id container;
   
    container = c1;
    [container print];
   
    container = c2;
    [container print];
   
     return 0;
}