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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:13:01+00:00 2026-05-13T08:13:01+00:00

I have a class which get all the bytes from a file, then it

  • 0

I have a class which get all the bytes from a file, then it splits up the bytes into three parts (a header, index and body) these 3 parts get passed along to 3 classes (called header, body and index) respectively. When the bytes in the three classes gets modified how can I pass these changes back up to the first class (the one that got the bytes from a file).
Must I have a property in each of the head, index and body classes called parentclass and then set the property when the classes are created?
This could get chaotic when the 3 classes are split up further.

A file is loaded and the bytes put into a property called data() then the bytes are split at certian places/offsets into three parts. One part gets put into a property called data() in a class called header the other two part are also put into properties called data but in another two classes called body and index. 
The user, through the form ui, modifies the data in the 3 classes (header, index and body) I want this data to be passed back to the first class combined and then it can be saved as a file. 

Or I just want to be able to referenc the data.  

  • 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-13T08:13:02+00:00Added an answer on May 13, 2026 at 8:13 am

    Concept

    Really it’s about code design. E.g. whether to use inheritance, composition, or both. The answer will also depend on the peripherals of what you’re trying to do (e.g. the code we don’t see in your question).

    Here’s just one set of ideas about allowing your parts to reintegrate themselves to a parent context after their bytes are changed.

    E.g.
    Require the “parent” instance (I’ll call it “context” in my example) to be passed to Header, Footer and Body when they are constructed; they can always contact the parent back at anytime to reassemble, access context members, or vice-versa. It’s kind of like the Value property you mentioned but makes it immutable after construction.

    alt text http://img194.yfrog.com/img194/278/bytesparts.png

    Sample Implementation

    We’ll make BytesContext read from the file and be responsible for splitting the bytes into other classes.

    For example, Dim c as New BytesContext() and c.ParseAllBytes() method is called as follows:

    Class BytesContext
    
        Sub ParseAllBytes()
    
            'READ ALL BYTES FROM FILE
    
            'INSTANTIATE PARTS
    
            ' Each part takes a reference to this context.
            Dim header As New HeaderBytes(Me)
            header.Data = someOfTheParsedBytes
    
            Dim body As New BodyBytes(Me, MaybeSomeBytesHere[])
    
            Dim footer As New FooterBytes(Me)
            ..etc.
    
            ' Can always know the context.
            Console.Write("Body context is " & body.Context.ToString())
    
        End Sub
    
        ' A method that puts the pieces back together.
        '
        Sub PutBackTogether(part As BasePart)
             If Typeof(part) Is HeaderBytes ...
             ...
             ElseIf Typeof(part) Is FooterBytes...
             ... etc.
        End Sub
    
    End Class
    

    HeaderBytes (and the other kinds of parts) take a reference to the context as an instantiation argument – they all pass it to a base class for safe keeping (see next snippet):

    Class HeaderBytes
        Inherits BasePart
    
        Sub New(ByVal context As BytesContext)
            MyBase.New(context) 'Store in base class.
        End Sub
    
        ''' REASSEMBLE SELF BACK INTO ORIGINAL
        ''' This instance can reference it's context and reintegrate its changes
        Sub Save()
            Context.PutBackTogether(Me)
        End Sub
    
    End Class
    
    Class FooterBytes
        Inherits BasePart
    '...same...
    
    Class BodyBytes
        Inherits BasePart
    '...same...
    

    Note: the above part has the ability to reintegrate its changes into the original context.

    This is the base part to share logic between parts, and keep a reference to the context for parts:

     Class BasePart
    
        '''Remember context.
        Private _context As BytesContext
    
        Public Sub New(ByVal context As BytesContext)
            If _context Is Nothing Then Throw New ArgumentNullException("context")
            _context = context
        End Sub
    
        ''' Getter allows access to context.
        ReadOnly Property Context() As BytesContext
            Get
                Return _context
            End Get
        End Property
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called Property which has nothing but get -methods. All the
I have a class with like 20 fields which get populated from SQL database
I have a manager class, which update json data from web, get values... The
I have a paginator class which should get the limit out of the config.xml
I have written the following handler class which is used to read images from
I have a method which calls for a classmethod of another class def get_interface_params_by_mac(self,
I have class which have one public method Start , one private method and
I have class LegacyClass which inherits OldBaseClass. I'm considering a change to introduce a
I have class Money which is an @Embeddable @Embeddable public class Money implements Serializable,
I have class A which extends the Activity class. This class is in package

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.