Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6175959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:00:53+00:00 2026-05-24T00:00:53+00:00

Now, I know this question is very opinion oriented because people generally design their

  • 0

Now, I know this question is very opinion oriented because people generally design their apps differently… However, I want to know if I’m doing something incorrectly, or generally frowned upon in the objective c programming community, or if you have any suggestions as to how an experienced obj c developer might design this differently…

LOCATION is a struct and BULLET is an enum defined in a Constants.h header file, BulletV is a subclass of UIView, and Bullet is a subclass of NSObject

I have the following code:

#import "Bullet.h"

@implementation Bullet

@synthesize Type;
@synthesize Location;
@synthesize Strength;

- (id)initWithLocation:(LOCATION)location Type:(BULLET)type Strength:(int)strength
{

    self = [super init];

    if (self)
    {
        self.Location = location;
        self.Type = type;
        self.Strength = strength;
    }

    return self;
}

@end

@implementation BulletV

@synthesize Type;

- (id)initWithLocation:(LOCATION)location Type:(BULLET)type
{
    self = [super initWithFrame:CGRectMake(location.x - 10.0, location.y - 2.0, 20.0, 40.0)];

    if (self)
    {
        self.center = CGPointMake(location.x, location.y);
        self.Type = type;
    }

    return self;
}

- (void)drawRect:(CGRect)rect
{
    switch (self.Type)
    {
        case Normal:
            self.backgroundColor = [UIColor redColor];
            break;
        default:
            break;
    }
}

@end

Now, I am relatively new to MVC.. but it seems like keeping the model and the view separate creates a whole lot of duplications, which i hate in my code..

For example, the fact that we have 2 of the same named Properties (Location and Type) utilized in these implementation blocks kind of bothers me, but I don’t know how I would do this any other way while still maintaining separation between the model and view.

Also, both init methods for the view and model are very similar, with the exception that the model also includes a strength parameter..

I have a very java-oriented mindset when programming, I like to have individual files for each object, and for each object to have a state and certain actions.. Now, this new design disallows for any actions to be utilized in these headers, because they need to be placed in a controller.

Any comments are welcome, if this is the way you would make a “bullet object” (more like just a rectangle) in your app, then feel free to comment so, but it just doesn’t seem right to me. Feel free to give your insights.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:00:53+00:00Added an answer on May 24, 2026 at 12:00 am

    I immediately see a couple of things I would change.

    First naming conventions. Properties and instance variables usually start with a lowercase character while classes start with an upper case character. Class names should be descriptive so BulletV would be clearer as BulletView, “BulletV” might be a “BulletView”, a “BulletVelocity”, or who knows what else.

    Secondly I would not allow a view to be responsible for it’s own position. A view should be responsible for it’s contents but not need to be aware of it’s position in or anything else about its superview.

    Instead I would consider what sort of object contains bullets with positions; a room, a level, or whatever. Let a view for that space position the views for whatever bullets it contains. An individual BulletView only need to decide how to draw itself based on the type of its bullet. Which, as Jano suggested, probably means you want to pass a bullet to the view’s designated initializer.

    Once you have that separation of responsibilities it hopefully makes sense for whatever object models the space containing bullets to manage their positions and possibly other behaviors like creating and destroying bullets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from this question , I now want to know how to stop
First off, I know this may be a very stupid question, so don't shoot
Now, I know this is completely subjective, so please don't flame me. I've never
I know I can do this: IDateTimeFactory dtf = MockRepository.GenerateStub<IDateTimeFactory>(); dtf.Now = new DateTime();
Hi this question or problem i have its very hard i have search and
This is going to be a very simple question, I have code that looks
Good afternoon, I'm sorry if this question is too silly, but I don't know
I know this question might be considered better on Stack UI, but I wanted
I know this question has been asked so many times before but I couldn't
I understand that this is a very broad question, but I was very curious

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.