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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:43:28+00:00 2026-05-11T19:43:28+00:00

I have a simple Address object in my domain that has a ToString() method

  • 0

I have a simple Address object in my domain that has a ToString() method that returns the address like this:

123 Test Ave

Appt 1A

Spokane, WA 99201

We will be displaying this in a webpage on several different occasions so it makes senses to add the functionality somewhere to display the address with Html formatting, but when I want to add a ToStringHtmlFormat() to my domain class it begins to start to smell funny.

I am probably being a bit picky, but where or how do you suggest accomplishing this to keep my domain class free of any Html stuff?

  • 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-11T19:43:28+00:00Added an answer on May 11, 2026 at 7:43 pm

    You could have an HTMLWriter that is able to “Visit” the domain classes and print out the stuff. Your domain classes then need an Accept method to accept the Visitor (Visitor pattern).

    In terms of flexibility and maintainability though I would go for some templating engine that contains your HTML and the access to those properties that you want printed out. Often more complex sites will also introduce something called a ViewModel, which prepares the data to be displayed in a way that is easily accessible by UI HTML Engines.

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

Sidebar

Related Questions

I have an address object that I want to create an equals method for.
I have an Address object that has properties AddressLine1, AddressLine2, Suburb, State, ZipCode. (there
Say I have a simple address class like below: public class Address { public
Using MySQL, I have a simple table that logs the IP Address that users
I have a simple form on an ASP.NET MVC site that I'm building. This
I have a simple IRenderable class that has members for position, scaling, and rotation:
I have a simple method in my model to create a NSDictionary object containing
I have looked at many examples seem to address this simple case. The string
I have simple php validation form that is halfway working. If you leave the
I have simple win service, that executes few tasks periodically. How should I pass

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.