|
Pete O'Hanlon wrote: It really depends what you're talking about. <layer>DRY just means don't repeat yourself. If the code you've taken is from the web, then modifying it to suit your needs is perfectly acceptable. I do agree that it's a PITA when somebody copies and modifies code that they don't understand (we see plenty of that in the forums).
In that case, you're repeating someone else. Having the same method repeated in your project would be a duplication, giving you two places to maintain that offer similar functionality.
I are Troll
|
|
|
|
|
I know what DRY means. I was just clarifying it because the wording could have been taken that way.
|
|
|
|
|
No offence meant, sorry
|
|
|
|
|
None taken. I thought I'd better put my reasoning there why I clarified.
|
|
|
|
|
|
It happens a lot when the KPI is the number of tasks completed. When you see someone doing it all the time and their KPI and wage is twice that of anyone else, you got to ask yourself is DRY worth the cost to you personally.
"You get that on the big jobs."
|
|
|
|
|
RobCroll wrote: It happens a lot when the KPI is the number of tasks completed. When you see
someone doing it all the time and their KPI and wage is twice that of anyone
else
That's a very interesting point, I don't know whether our KPI's are based on the number of tasks completed. There certainly are times where people seem to checkin bad code, and are unable to explain why they did it. However, I don't think the management would have a rule like this. They are trying to improve the code quality, although there is always a drive to get work done quickly.
RobCroll wrote: you got to ask yourself is DRY worth the cost to you personally
Well, I suppose you need to decide what is most important to you. Do we want to be software developers or hackers? We spend a lot of our life working, so I want to make sure that I enjoy my work. However, if you're in a company that has bad KPI's then it's probably best to find a company that doesn't. I think it's probably hard to find a company with a good development team though
I'm a developer because I enjoy developing software. It's becoming more difficult for me to enjoy it when I know that the code is full of rubbish. I sometimes think that a management/teamleader position would be a better place for me because I could have some influence over the quality without actually having to work with the rubbish. Maybe small companies (with a one or two man team) are the way forward.
|
|
|
|
|
I am an almost religious advocate of the DRY principle (I have broken it a few times but either through extreme need or the decision wasn't mine to make.. and believe me, in that case, i fought it bitterly)
In my experience, there are a LOT of developers out there happy to throw the DRY principle away and they cite the following excuses:
- Time constraints
- Budget constraints
- Too high impact on existing (flawed) design
- Inexperience (excuse usually given by someone else on their behalf)
Personally i find i generally design a system in my head, then as I'm coding it spot areas where I'm in danger of breaching the DRY principle and, in rooting these out, a better design surfaces.
I guess there are two types of developer, the first measures their success in designing and building an application by the elegance of the end design and its adherence to good coding practice, the second measures their success by meeting performance targets.
I have worked in environments where some developers were bringing in unmaintainable messes early and under budget and were praised by the PHBs as examples for the rest of us coders (scraping by the budgets with elegant solutions)
Sloppy coding can give you a short-term gain, but its gonna bite you in the arse eventually
IsRanting = false;
|
|
|
|
|
I'd like to gain an overview of the whens and whys about state specifications/implementations.
How do you go OOP when specifying states? Or do you prefer an enum? ints? ...
References are also appreciated.
I am very mixed about this topic, so you will get no religious opinions from here.
Thanks!
Keld Ølykke
|
|
|
|
|
I'll go for enum over int every time because there probably isn't going to be billions of states and by strongly typing the values, it makes the design a lot more robust and maintainable. MyState.Enabled as opposed to 1 is a lot easier to work with.
"You get that on the big jobs."
|
|
|
|
|
|
Hi All,
I am developing a library component which requires some global settings. Personally I don’t like to maintain an xml configuration file for this.
An idea strikes for me that to write an abstract class with an abstract method which can override and set global setting by the implementers of this library.
The abstract class will look like something like this.
public abstract class LibSetting
{
public int MaxCount { get; set; }
public abstract void SetCount();
}
The end users will implement this abstract class in their application is as follows.
public class MySetting : LibSetting
{
public override void SetCount()
{
MaxCount = 100;
}
}
To get the end user setting from my library, I am using following code.
public int ShowCount()
{
Assembly asm = Assembly.GetCallingAssembly();
IEnumerable<Type> types = asm.GetTypes().Where(t => t.IsClass && t.BaseType == typeof(LibSetting));
LibSetting setting =(LibSetting) asm.CreateInstance(types.First().FullName);
setting.SetCount();
return setting.MaxCount;
}
This will work perfectly. My doubt is that, is it feasible in architecture level of view? I think the performance of read an xml file and loading a class using reflection would be same ( I didn’t test it). So is this a good practice? Kindly advice me on this.
Thanks and Regards,
Kannan
|
|
|
|
|
Hi Kannan,
Your inheritance approach seems fine.
I have the following things that you can ponder about:
1) Isn't the user's call to a setter a little backwards?
Another approach is just to require a getter from the user's concrete class e.g.
public abstract class LibSetting
{
public abstract int MaxCount { get; }
}
2) Furthermore, you could supply the user with good default settings e.g.
public abstract class LibSetting
{
public virtual int MaxCount
{
get { return 100; }
}
}
Hope it makes sense...
Regards, Keld Ølykke
|
|
|
|
|
Hello,
I have been designing a cross-platform GUI application using JUCE framework and need some help in designing it.
The GUI will be used for configuring the hardware/device.
I did layering for the application as below.
- Presentation Layer
- Controller Layer
- Model Layer
- Communcation Layer
I’ll explain each of them as below.
Model Layer: It contains the actual data that is displayed in the UI and stored in the hardware/device.
For e.g Device Information (ID, Name, version number)
Presentation Layer: It displays the information present in the Model/Hardware or the information after being manipulated in the Model. Mainly, it acts a View.
Controller Layer: It controls the requests coming from presentation layer and hardware/model layer.
Communication Layer: It communicates with the actual hardware through some protocol and send/receive from/to controller.
So, the basic flow from UI to device will be
Presentation -> Controller -> Communication -> H/W -> Receive message from H/W -> Communication -> controller -> Model and Presentation
And reverse would be
Receive message from H/W -> communication -> controller -> model and presentation.
Here are my questions w.r.t design.
- Model will have entities such as Employee, Department which will be used inside the controller. Shall I create a EmployeeController and departmentController OR should I have a single controller class only
- If I wanted to show information of an emplyee in a department in UI, should I create corresponding views in the UI such as employeeView and departmentView.
- What patterns we can apply for different layers, especially for GUI
- Where should I write the observer pattern in order to update the UI when there is a change in the value of the Model.
- Appreciate if someone can provide me an example for Loosly coupled GUI application in C++ and that interacts with the hardware.
Please let me know for any clarification.
Thanks in advance for your time and effort.
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
Looking for a third party chat service where site visitors can live chat with reps and during off hours have an automated response for basic visitor questions.
|
|
|
|
|
Your question ain't really related to 'Desgin and Architecture'. I think you will be better of, asking this question in one of the forums related to the technology you are using, eg. asp.net.
|
|
|
|
|
Try Google, there are lots of ready made packages around.
I must get a clever new signature for 2011.
|
|
|
|
|
I've developed on an application for quiet long now, and it consist of 2 sub systems, 1 for Marketing and 1 for Management. They have an seperated DB each. Now I have an UI that have to pick information in both databases, and I wondered if my controller pattern was correct, since I somehow got the idea that a UI that have connection to both Controller Facades, must be somehow incorrect?
My original setup was like this:
[UI]
------Controllers------
[Business Logic]
------Datacontext------
MarketingDB | ManagementDB
I don't know if it give you any sense? The controller on the drawing consist of the 2 controllers described above. Would it be right to make an on-top controller and call that one FrontController, so ALL UI's are connection to the FrontController no matter if they are Marketing UIs or Management UIs? Imo that gives you the ultimate of low coupling between UI and business layer, and lowest coupling between the Controllers and the UI layer, but I don't know if this is 'correct' or wrong? What is your oppinion???
I have two drawings to show the concept I wanted to do:
http://img192.imageshack.us/i/controllerdomaincontrol.jpg/[^]
ONLY FrontController:
http://img62.imageshack.us/i/controllerfrontcontroll.jpg/[^]
Which one would you prefer as correct architecture? And why?
|
|
|
|
|
I prefer front controller because by adding a layer you can abstract your sub controllers and stimulating immagination
Piccadilly Yum Yum
|
|
|
|
|
But won't it just be another class class with duplicated code, containing all the method's from sub-controllers? Or are there any smart way to do it?
|
|
|
|
|
It depends on what is the job of controllers, your architecture is not the only possible, i post a fragment from wikipedia about architectures :
Architecture description languages
Architecture description languages (ADLs) are used to describe a Software Architecture. Several different ADLs have been developed by different organizations, including AADL (SAE standard), Wright (developed by Carnegie Mellon), Acme (developed by Carnegie Mellon), xADL (developed by UCI), Darwin (developed by Imperial College London), DAOP-ADL (developed by University of Málaga), and ByADL (University of L'Aquila, Italy). Common elements of an ADL are component, connector and configuration.
Piccadilly Yum Yum
|
|
|
|
|
I'm looking for a good way to send notifications to our group when the results of a stored procedure cross a certain threshold. An example would be we have a table that acts as a queue for processing and when the number of records in a processing status is greater than say 10 I would like to receive an email. Is there a better way of doing this other than running a windows service thats polling the database? Thanks in advance.
Greg
modified on Monday, March 7, 2011 5:33 PM
|
|
|
|
|
gbovee wrote: Is there a better way of doing this other than running a windows service thats polling the database?
Since you only get a value when you execute it, there'd be no alternative to polling. You'd have to execute the sproc to see if the value changed.
What does the sproc do? Perhaps the logic can be moved elsewhere?
I are Troll
|
|
|
|
|
Hi,
I know, a well designed architecture should not allow a presentation layer to talk to Data Access Layer. Rather Presentation layer should talk to Business Logic Layer and Business Logic Layer should talk to Data access layer.
In my Data access layer, I have method
public static employee GetEmployee(string emailAddress)
{
using (EmployeeDBDataContext myDbContext = new EmployeeDBDataContext())
{
employee empRecord = myDbContext.employees.Where(aRec => aRec.emailAddress == emailAddress).ToArray().SingleOrDefault();
return empRecord;
}
}
My Presentation Layer's job is to display the properties of the employee object directly to the UI, where I do not even need to write any code for that.
Ok, now, should I create a thin Business Logic layer just to mediate the call of Presentation layer ? Then, it may look very messy as I will have to create a set of methods in BLL duplicating the method signature from DAL. Would you please tell me what could be a better practice ?
modified on Monday, February 28, 2011 5:12 AM
|
|
|
|
|
My first thought looking at this example is that you are awfully trusting. By that I mean that you are trusting input that has not been validated. What happens if email is an empty string, or not a valid email format? This is the type of thing that a well constructed business layer helps to cope with.
|
|
|
|