Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need suggestions for C# project Pin
Eddy Vluggen29-Jul-13 3:20
professionalEddy Vluggen29-Jul-13 3:20 
AnswerRe: Need suggestions for C# project Pin
Amir Mohammad Nasrollahi29-Jul-13 4:19
professionalAmir Mohammad Nasrollahi29-Jul-13 4:19 
AnswerRe: Need suggestions for C# project Pin
AmitGajjar30-Jul-13 2:49
professionalAmitGajjar30-Jul-13 2:49 
AnswerRe: Need suggestions for C# project Pin
Alan Balkany30-Jul-13 4:35
Alan Balkany30-Jul-13 4:35 
QuestionDoes this code is object oriented or not ? Pin
stmk6929-Jul-13 1:05
stmk6929-Jul-13 1:05 
GeneralRe: Does this code is object oriented or not ? Pin
harold aptroot29-Jul-13 1:15
harold aptroot29-Jul-13 1:15 
GeneralRe: Does this code is object oriented or not ? Pin
ZurdoDev29-Jul-13 4:42
professionalZurdoDev29-Jul-13 4:42 
AnswerRe: Does this code is object oriented or not ? Pin
Eddy Vluggen29-Jul-13 9:05
professionalEddy Vluggen29-Jul-13 9:05 
stmk69 wrote:
Please tell me if this code bellow object oriented or not. If it is not what changes that are needed to become an Object oriented?
That would give you an example, but it's not said that the example would help in determining whether the next class you encounter is OO or not. It's more efficient to research the difference between non-OO and OO-code.

Non OO-code in C# (procedural code translated to C#)
C#
static class X
{
    public static void Method1(string arg1, int arg2, bool arg3, bool arg4)
    {
      // some stuff
    }
    public static void Method2(int arg2, bool arg4)
    {
      // related stuffs
    }
    public static bool AllBoolArgsTrue(bool arg3, bool arg4)
    {
       return ((true == arg3) && (true == arg4));
    }
}
Take note that it's a list of procedures that you can call, along with some parameters, without instantiating the object. The proper OO-version of this code would look similar to the code below;
C#
class X
{
    string arg1;
    int arg2;
    bool arg3;
    bool arg4;

    public X(string arg1, int arg2, bool arg3, bool arg4)
    {
      // assign constructor param-values to fields/properties for reuse in "this" object.
    }

    public void Method1()
    {
      // some stuff
    }
    public void Method2()
    {
      // related stuffs
    }
    public bool AllBoolArgsTrue()
    {
       return ((true == this.arg3) && (true == this.arg4));
    }
}
The example might suck, but it shows clearly why we prefer OO-code; it's more readable, and hence, easier to maintain. Instead of passing a variable to each method of the class, we pass it to the object. Stuff that belongs together is grouped together - and each object becomes an easy testable black-box. No more spaghetti-code!

This would be the essence; good OO-code has more features, like inheritance - but one does not "always" require a base-class, it's not a mandatory construction. On the contrary, if it doesn't add anything (beyond complexity) then it should be omitted.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

QuestionC# Reflection Pin
KamranJavidSolutions29-Jul-13 0:25
KamranJavidSolutions29-Jul-13 0:25 
AnswerRe: C# Reflection Pin
Pete O'Hanlon29-Jul-13 1:54
mvePete O'Hanlon29-Jul-13 1:54 
GeneralRe: C# Reflection Pin
KamranJavidSolutions29-Jul-13 2:23
KamranJavidSolutions29-Jul-13 2:23 
AnswerRe: C# Reflection Pin
Manfred Rudolf Bihy29-Jul-13 2:30
professionalManfred Rudolf Bihy29-Jul-13 2:30 
QuestionError: External table is not in the expected format Pin
NarVish28-Jul-13 21:26
NarVish28-Jul-13 21:26 
AnswerRe: Error: External table is not in the expected format Pin
Richard MacCutchan28-Jul-13 22:29
mveRichard MacCutchan28-Jul-13 22:29 
GeneralRe: Error: External table is not in the expected format Pin
NarVish28-Jul-13 23:49
NarVish28-Jul-13 23:49 
GeneralRe: Error: External table is not in the expected format Pin
Richard MacCutchan29-Jul-13 0:01
mveRichard MacCutchan29-Jul-13 0:01 
GeneralRe: Error: External table is not in the expected format Pin
NarVish29-Jul-13 0:14
NarVish29-Jul-13 0:14 
GeneralRe: Error: External table is not in the expected format Pin
Richard MacCutchan29-Jul-13 0:20
mveRichard MacCutchan29-Jul-13 0:20 
GeneralRe: Error: External table is not in the expected format Pin
NarVish29-Jul-13 0:52
NarVish29-Jul-13 0:52 
QuestionScrollViewer adjusting HorizontalOffset in VirtualizingStackPanel Pin
Revolty28-Jul-13 3:39
Revolty28-Jul-13 3:39 
QuestionNeed help to use powershell script with two foreach in c# Pin
Member 981625927-Jul-13 19:37
Member 981625927-Jul-13 19:37 
AnswerRe: Need help to use powershell script with two foreach in c# Pin
Richard MacCutchan28-Jul-13 1:04
mveRichard MacCutchan28-Jul-13 1:04 
QuestionHow to use powershell hash table in c#. Pin
Member 981625927-Jul-13 19:36
Member 981625927-Jul-13 19:36 
QuestionDisplay RichTextBox string in RDLC report Pin
cdpsource25-Jul-13 23:38
cdpsource25-Jul-13 23:38 
AnswerRe: Display RichTextBox string in RDLC report Pin
Richard Deeming26-Jul-13 1:44
mveRichard Deeming26-Jul-13 1:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.