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 7830737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:23:18+00:00 2026-06-02T11:23:18+00:00

Im trying to create a StandardMidiFile Object, It will contain a HeaderChunk Object and

  • 0

Im trying to create a StandardMidiFile Object,
It will contain a HeaderChunk Object
and a TrackChunk object.

The TrackChunk Object will contain MidiEvent objects.

So when I create this StandardMidiFile Object,
I want it’s constructor to construct & contain the other objects.

But, when the TrackChunk Object is created it first needs to call a getter method in a GUI-UserControl Class that will determine the total Length of the all MidiEvents in bytes.
And that value will then be used in constructing the TrackChunk.

Is it good OOP practice to call a method inside a constructor?

  • 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-06-02T11:23:28+00:00Added an answer on June 2, 2026 at 11:23 am

    What I would do is pass in the track length as a constructor parameter.

    class StandardMidiFile
    {
        HeaderChunk header;
        TrackChunk track;
    
        public StandardMidiFile()
        {
            var trackLength = // call GUI-UserControl class to get value
            header = new HeaderChunk();
            track = new TrackChunk(trackLength);
        }
    }
    
    class HeaderChunk
    {
        // blah blah blah
    }
    
    class TrackChunk
    {
        // blah blah blah
    
        public TrackChunk(var trackLength)
        {
            // Do stuff here.
        }
    }
    

    Of course, it really depends on the rest of your design. If TrackChunk is intended to be only an object used in StandardMidiFile, then this makes more sense to me. Either way is “correct”, I believe.

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

Sidebar

Related Questions

Trying to create the following routine in MySQL Workbench yields a This object's DDL
I've been trying create this simple ish to-do list web app using JavaScript &
I am trying create a delegate representation of constructor by emitting a Dynamic Method,
Trying to create a background-image slideshow and am getting this error... This is the
Trying to create a mapper for an Microsoft Office object to POCO's and found
Trying to create COM -object on server. code is: var myGuid = new Guid(530A1815-820C-11D3-BBB7-008048DE406A);
All, I am trying create a 'to & fro' animation using jquery animate &
Trying to create a very piece of validation to prevent spammers. I want a
I'm trying create this function such that if any key besides any of the
I am trying create a search box which will search datatables. The search box

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.