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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:44:44+00:00 2026-05-27T08:44:44+00:00

Currently I am constructing a view object from a search result (which comes from

  • 0

Currently I am constructing a view object from a search result (which comes from a different single resource) like this:

ViewObject vo = searchResultToViewObjectMapper.map(searchResult);

This works fine.

However, now I want to add some pictures. These pictures are url’s and I can only determine their location via some other resource than the search result comes from.

My first thought would be to use the Builder Pattern, it would become:

ViewObject vo = viewObjectBuilder.build(searchResult);

and the viewObjectBuilder would do something like this:

private SomeOtherResourceRepository someOtherResourceRepo;

private SomeUrlBuilder someUrlBuilder;

private SearchResultToViewObjectMapper searchResultToViewObjectMapper;

public ViewObject build(SearchResult) {
    ViewObject vo = searchResultToViewObjectMapper.map(searchResult);

    String reference = someOtherResourceRepo.getOtherResource(searchResult);

    String urlToOtherResource = someUrlBuilder.build(reference);
    vo.setUrlToOtherResource(reference);

    return vo;
}

The question is: Is this a good way to this? Or are there other (better) ways? I’m also curious how a DDD approach would do this.

Thanks in advance!

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

    Using a factory will work for you if you have all of the resources available before you create your object – just pass them on to the factory method and it will do the magic.

    If the object you are creating (the view) is created in steps – i.e. first you only have the searchResult, after this you dig more and get some extra URLs which are added to the view, and then you do some more searching for more information, and only then you want to get the view object, a builder would be a better solution.

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

Sidebar

Related Questions

I'm currently constructing loggers (with configgy) like this: class MyClass { private val log
Currently I'm doing some unit tests which are executed from bash. Unit tests are
I am currently constructing an OWL ontology, which - until very recently classified rapidly
I'm constructing a program which uses mprotect() to restrict a block of memory from
I am implementing a suffix trie (this is different from a suffix tree) that
I am currently constructing a Carputer front end and one function that it needs
I currently have a set of buttons which when pressed, update an element of
I'm currently developing a small business database application for which we plan to go
i'm currently constructing some kind of mini-framework for a project, and come up with
Currently, I am constructing an XML document in PHP that will yield the following:

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.