|
I have seldom written class along those lines, although the very useful LINQ does!
One alternative I like is object initializer:
var o = new MyObject
{
Name = "foo",
ID = Guid.NewGuid(),
Foo = new Bar
{
Snafu = true,
},
};
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Thank you for the reply!
|
|
|
|
|
I use them for classes where there are logically linked discrete behaviours, such as validation. When you validate a property it is common to check multiple things on it, and a fluent interface is a nice way to do this.
|
|
|
|
|
Pete O'Hanlon wrote: such as validation
Thanks for the reply, that's a good idea I may start applying that concept also
|
|
|
|
|
venomation wrote: What scenarios would you use them in?
Any place where I want to help someone who is "using" that part of the code. It makes life easier for those who need to work with it, just a good documentation or an example would.
venomation wrote: Alternatives?
I prefer to implement the Decorator pattern
I are Troll
|
|
|
|
|
Thanks for the comment
Eddy Vluggen wrote: I prefer to implement the Decorator pattern
I am familiar with that design pattern, but doesn't that seem more complicated than a simple fluent design?
Or is there a way of making a fluent design also a decorator...?
|
|
|
|
|
venomation wrote: I am familiar with that design pattern, but doesn't that seem more complicated than a simple fluent design?
I guess it is. A template of the pattern makes it quite easy to implement, it just takes a bit more time. Might depend on what structures you're most familiair with.
venomation wrote: Or is there a way of making a fluent design also a decorator...?
Not that I'm aware of.
I are Troll
|
|
|
|
|
|
You're welcome
|
|
|
|
|
venomation wrote: What scenarios would you use them in?
I doubt I would ever use them.
Especially since the only touted benefit is that it makes it more 'readable' which is a subjective term that one can use to rationalize almost anything.
venomation wrote: I use them for objects that require too many arguments or optional inputs.
I don't see that your example has "too many arguments" in the first place.
But generally something that does in fact have too many arguments might have a design problem. And certainly if one sees a lot of code like that (versus say 1 out of 1000) then it would seem very likely that there are design problems.
|
|
|
|
|
jschell wrote: might have a design problem
Thanks for the comment!
|
|
|
|
|
I think it has a needless apostrophe.
|
|
|
|
|
I am having a nightmare about table exceptions such as if item is not found in the table
a message should be given to the user by using try-throw-catch or if-else statements.
i don't have any idea
Any help would be gratefully received.
|
|
|
|
|
Please provide the code you have written, especially the API you are using to retrieve the record from a table.
Suggest you to read the documentation for the API. It might guide you to handle this specific scenario.
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
Thanks for your attention.I saw that i used same name for two different variables . issue solved
|
|
|
|
|
your question is little bit confusing for me about table exception.
please mentioned which kind of table is it related with database or not.
as possible give some more information or some code so we can justify what is problem.
|
|
|
|
|
i need to use the local language font (sinhala) with textbox in my app in xp, so the user can type in the local language.
for this i'm using ttf font. i can set the font to textbox without any problem. but when i'm typing in the text box it
shows the english font,but i tried
char[] ch = {'\u0db8' };
textBox2.Text = new string(ch);
in the form load and it showed the correct letter, but when type in the text box still only the english letters. (at the same time i set true regional setting->language->install files for east asian languages,when i set this off , characters in the textbox shows as black squares)
so any one got any idea why this happens, but i tried the same app with the same font in win 7 and it works perfect, but i need this app to run in xp.
thanx in advance.
|
|
|
|
|
prasadbuddhika wrote: but when i'm typing in the text box it shows the english font
That's because the font will be a Unicode font. In that case, you need to emit proper Unicode code points for Sinhala to get the characters displayed correctly. This is why the text set by you at the load is showing correctly but when you type you are entering English characters which is nowhere in the Sinhala code point range.
prasadbuddhika wrote: time i set true regional setting->language->install files for east asian languages,when i set this off , characters in the textbox shows as black squares
Windows XP requires this to be installed to get the proper rendering. From Windows 7 onwards, this comes by default and you don't have to install separately.
I think you have two choices here.
1 - Use a Sinhala ASCII font which you can supply with your application. In a ASCII font, English characters will be mapped to a Sinhala character. So typing using a English keyboard will show the Sinhala letter. When user wants the text out from the textbox, you need to convert it to Unicode.
2 - Interpret English characters and emit the Sinhala Unicode encoded (UTF8 or UTF16) characters.
prasadbuddhika wrote: i tried the same app with the same font in win 7 and it works perfect
I can't think of how this will work on Windows 7 with a Unicode font other than using the methods that I explained.
Best wishes,
Navaneeth
|
|
|
|
|
Hi everyone. I want to develop an application that runs in background and changes the function of each key of the keyboard. for example if i press the letter Q i want to send some other key( Amharic letter) to the active application. I've downloaded the utf-8 unicode characters of all Amharic letters. How can i achieve this? TNX in advance
|
|
|
|
|
You could write your own keyboard layout, or provide a general hook into teh keyboard itself.
Layout:
You are on your own: I know nothing!
Hooking:
There is an article here A Simple C# Global Low Level Keyboard Hook[^] which will give you the basics.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Google found these suggestions[^] which may help you.
I must get a clever new signature for 2011.
|
|
|
|
|
|
Can you look into this app of mine, read about it and say your opinion about what problems i encounter in it?
I made an archive with some sample files and my app that use them. Its simpler and faster this way.
Link is here: http://www.sendspace.com/file/y4jc49 [download zTesting.zip]
Inside zip you will find [testu4.exe] app.
This is the content or the "Readme" that you will find inside, also.
I want to know something relating file handling. I dont mean in code but in real life.
Off, it's hard to put it into words.
The best way of my intent, is to give you an example of what i did (and not finished yet).
---------------------------------
Description of the program:
---------------------------------
Open the program [testu4.exe].
My software can list those txt files in custom rows.
Can search through their file names[up] and also through their contents[body].
When the search is finish, I have 2 options to show the content -> (Context - Concentrated)
I have an option to [show/Close all] rows. And a [Open File] that open the real file (not the text file).
The [Extract All] and [Back/Next] buttons are not implemented yet.
---------------------------------
Its purpose:
---------------------------------
I am not satisfied with it.I don't know why. Maybe you can suggest something to enlighten me.
-
The purpose of it, is to be able to quickly see inside tutorials and also, to quickly manipulate them.
Another purpose of it is to add manually files and directories and with this little app to be able to see inside them all at once.
-
Into a directory, I put together a couple of simple txt files.
Then, some html,pdf and docx files. These files I convert to txt file.
So, in the end I have a LOT of txt files.
The idea, for converting all into txt, is like so: [inside txt files, a c# software can search very quickly].
The name of the file will reflect its contents.
-
---------------------------------
TODO
---------------------------------
In the future I will add a treeview to it and the option to create a new file(txt,docx,or whatever).
I think to a drag option for files between them and a sort files.
It will be able to extract txt files from docx,html,xls,etc.
---------------------------------
------------------------------------------------------------------------------------------------------------------------------------
OK, so i hope you understand from this example what I want to create and its purpose.
What I want from you to tell me, well, I really don't know exactly for sure, but give me some suggestions to continue from.
The application is building, slowly but surely. I don't need special attention from you to its design. I want to give me an idea of how to work with these files. I mean, I want to be clear for me in the first place...then the app will do the hard work.
I am a bit ashamed for myself because of this confuse situation. But i need some help.
What i need to clarify in my head ? Or between these files?
Now I understand that this is the real programming problem that all will face in the end.
I have an idea. Maybe when I will put it to a real work, then the real problems will appear and also I will know what to repair and fix.
But its a long shot because i want it to remain a "AllPurpose" software, and not a specific one. For example, i want to see html,photoshop,c#,assembly tutorials with it, and not only c# tutorials. The problems will arrive from this corner only, and I will fix it to do its part of work in this direction, not in all. Or maybe i am thinking too much.
Give me some directions, something to start with,or clarify for me.
|
|
|
|
|
No.
Sorry, but I am not in the habit of downloading and executing unknown files from strangers. Would you?
Try describing things, instead of expecting us to download a program that could do anything when we run it...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Ok, I know how it sounds, but I assure you that is not a virus or anything dangerous.
It's a simple project that is in testing form. Nothing more.
Its faster and simpler to view what i have done than to explain.
I really need some help from you guys.
Give me an alternative and I will try to make it.
Thank you.
|
|
|
|