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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:08:58+00:00 2026-06-12T11:08:58+00:00

I always seem to fall back on the Factory Pattern/Inheritance for code reuse, and

  • 0

I always seem to fall back on the Factory Pattern/Inheritance for code reuse, and have been reading about composition over inheritance and do see the benefits of the loose coupling. You definitely get dependencies with inheritance. So I am trying to wrap my head around a pattern for “process” objects.

They all basically,

  • get their “environmental variables” from a database,
  • Get a list of files,
  • Process/convert each file (think convert XML to CSV), which entails
    • Reading the file, line by line
    • Writing a file into a another format, line by line
    • updating status (writing status to a database)

Get a list of files may mean get a list of files from a local directory, or get a list of files from a remote FTP site.

The thing that I’m struggling with, with compositoin is CODE REUSE. Using inheritance, if I had a Base Abstract Class, I could put my GetEnvironment, UpdateStatus, methods in the base class and the child classes would get them for free. How would I be able to get code reuse like this using composition? I could have helper classes, but I would essentially repeat the boilerplate use of these helper classes in each “process” class. I can work up some pseudo code if necessary.

  • 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-12T11:09:00+00:00Added an answer on June 12, 2026 at 11:09 am

    Given the details in the question, I would have my solution as follows:

    • Environment
      • Domain object that holds the environment details.
    • EnvironmentDAO and DBEnvironmentDAO
      • The interface and the DB-backed implementation to build the Environment domain object.
    • AToBConverter
      • Takes a file and reference to the environment object
      • performs the transformation, writes to another file and updates the status in the DB
    • Launcher
      • Takes a list of files.
      • Retrieves the Environment from the database using the DAO.
      • Employs a scalable mechanim (like ExecutorService) to run the AToBConverters in parallel.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing wordpress plugins for a while now and i always seem
I'm trying to pass a string to chdir(). But I always seem to have
I've been struggling with how to structure my 3-tier applications. I always seem to
I always seem to encounter this dilemma when writing low level code for MCU's.
I've been writing Windows Services for a while and they always seem to work
I always seem to have problems with CSS layouts. What is the best to
I always seem to have trouble with xpath axis expressions... In some expressions I
Here is some sample code...I always seem to get a ClassCastException...anybody point out what
I've been having this problem for while now, but always seem to put off
OK, I know there have already been questions about getting started with TDD ..

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.