Skip to main content
Code Review

Return to Answer

replaced http://softwareengineering.stackexchange.com/ with https://softwareengineering.stackexchange.com/
Source Link

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit


I pulled this up from the comments

... what do you mean by real DateTime objects.I was converting to string cause I was passing this to the .aspx page for visualization, similar to a ViewModel but not sure if I can call it this way.

Regarding datetimes as strings: Each differently formatted datetime essentially becomes its own type. I must give each format special handling or else code is blowing up. I cannot pass these things except to other specialized methods; that means duplicate code. Datetime arithmetic is severely hampered. Converting to a real DateTime defaults undefined parts (parts not in the string) which will probably cause errors down stream. And passing a date-as-string is a violation of SRP. Let the client decide how it want's the date to look.

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit


I pulled this up from the comments

... what do you mean by real DateTime objects.I was converting to string cause I was passing this to the .aspx page for visualization, similar to a ViewModel but not sure if I can call it this way.

Regarding datetimes as strings: Each differently formatted datetime essentially becomes its own type. I must give each format special handling or else code is blowing up. I cannot pass these things except to other specialized methods; that means duplicate code. Datetime arithmetic is severely hampered. Converting to a real DateTime defaults undefined parts (parts not in the string) which will probably cause errors down stream. And passing a date-as-string is a violation of SRP. Let the client decide how it want's the date to look.

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit


I pulled this up from the comments

... what do you mean by real DateTime objects.I was converting to string cause I was passing this to the .aspx page for visualization, similar to a ViewModel but not sure if I can call it this way.

Regarding datetimes as strings: Each differently formatted datetime essentially becomes its own type. I must give each format special handling or else code is blowing up. I cannot pass these things except to other specialized methods; that means duplicate code. Datetime arithmetic is severely hampered. Converting to a real DateTime defaults undefined parts (parts not in the string) which will probably cause errors down stream. And passing a date-as-string is a violation of SRP. Let the client decide how it want's the date to look.

added 805 characters in body
Source Link
radarbob
  • 8.2k
  • 21
  • 35

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit


I pulled this up from the comments

... what do you mean by real DateTime objects.I was converting to string cause I was passing this to the .aspx page for visualization, similar to a ViewModel but not sure if I can call it this way.

Regarding datetimes as strings: Each differently formatted datetime essentially becomes its own type. I must give each format special handling or else code is blowing up. I cannot pass these things except to other specialized methods; that means duplicate code. Datetime arithmetic is severely hampered. Converting to a real DateTime defaults undefined parts (parts not in the string) which will probably cause errors down stream. And passing a date-as-string is a violation of SRP. Let the client decide how it want's the date to look.

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit


I pulled this up from the comments

... what do you mean by real DateTime objects.I was converting to string cause I was passing this to the .aspx page for visualization, similar to a ViewModel but not sure if I can call it this way.

Regarding datetimes as strings: Each differently formatted datetime essentially becomes its own type. I must give each format special handling or else code is blowing up. I cannot pass these things except to other specialized methods; that means duplicate code. Datetime arithmetic is severely hampered. Converting to a real DateTime defaults undefined parts (parts not in the string) which will probably cause errors down stream. And passing a date-as-string is a violation of SRP. Let the client decide how it want's the date to look.

added 129 characters in body
Source Link
radarbob
  • 8.2k
  • 21
  • 35

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit

I know this logic has to happen or be written somewhere, even if it's in a different manner, but I am not sure how to approach it.

Class Design

A good class model manages complexity. A good class hides state and exposes functionality.

This code is deferring all the details of all the construction of all the objects to the very last possible moment and then instantiates the entire HotelInformation universe in a big bang. This is the antithesis of object oriented design.

Instead, a logical hierarchy of objects gets built up in layers if you will. With each class/object encapsulating its own state details the overall effect is that at any given point in a class composition, the construction is simple.


Random Observations

  • Be wary of using LINQ as an inappropriate device for things that should be encapsulated in a class
  • Use real DateTime objects.
  • Think real hard about each class and its purpose. Apply the Single Responsibility Principle mercilessly. SRP is the most important "bizz" of the SOLID buzzword.

Edit

Refactoring.

It's nice to say do the right thing from the beginning, but it is refactoring that will save your sanity with that codebase. You must get a long term perspective and accept that it will take patience, persistence, and study. But it is your ball of mud now and getting control of it is a very satisfying experience.

  • Refactoring: Improving the Design of Existing Code
    • get. this. book.
    • The seminal work on the subject. A recipe cookbook for specific refactoring problems.
  • Brownfield Application Development with .NET
  • Working with Legacy Code
  • Big Ball of Mud
  • My recent watch on the subject. Yes, it's about refactoring, not Ruby

2 Big Bangs for the Buck

end Edit

add refactoring comments
Source Link
radarbob
  • 8.2k
  • 21
  • 35
Loading
added 349 characters in body
Source Link
radarbob
  • 8.2k
  • 21
  • 35
Loading
Source Link
radarbob
  • 8.2k
  • 21
  • 35
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /