|
|
Difference between Abstract classes and Interface
Little background:
A real world entity is represented in an OOP world as object. Objects are defined as classes any language.
A class defines objects in two aspects
Object's characteristics - Data Members
Object's functionality - Member functions
So, when the classes that are forced to provide implementations of the functions prototypes that are defined in either ‘interfaces’ or a ‘abstract class’ are not belonging to the same family (having some inherited parental characteristics from same parent directly or indirectly) but are rather related through some functionalities then 100% we will go with interface and if above said classes are belonging to same family then we should go with abstract class inheritance.
Also in case of inheritance as everything is a specialization of base parent object so there is allowance of providing some default definitions of the functions that are needed to be implemented further by specialized classes. This is not any way allowed in interfaces because implementing classes are not belonging to same family and are not any way related by characteristics.
An Example:
We have four real world objects:
• Airplane
• Bird
• Sparrow
• Eagle
We have one method that is a functionality of all above objects
• Fly
Now all objects share common functionality flying in air but differ in the mechanism they use to fly.
Also by close look we see that in general there is some common characteristics (as well as some common functionalities) between Sparrow and Eagle that can be a part of common class Bird (that has to be abstract because there is no real thing like bird!). But any way Airplane can't be related to Bird or its specialized classes Sparrow and Eagle.
So if want to expose fly functionality to outer world and want their implementations in Airplane and Sparrow (or any bird), so I will 100% go for Interface and Abstract classes will be a big NO!
But if we exclude Airplane want that fly functionality is exposed to outer world and its implementing classes are Bird, Sparrow and Eagle then 'Abstract Classes' is the best of best choice.
Happy programming! Please feel free in writing to me for further clarifications on other OOP concepts (im.himanshu2006@gmail.com)
Himanshu
|
|
|
|
|
Hi all
I created a thead and textbox in a class and try to set value of textbox from another created thread.
But error comes that Resources held by main thread as TextBoxes are held by main thread. What to do in this case?
#Abhi#
|
|
|
|
|
Take a look at this article here on CP: What's up with BeginInvoke?[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Only the main thread can update an item on a form.
|
|
|
|
|
Hi,
in .NET 1.x you could try it from another thread and it might work (most of the time),
or it could result in forms with a white menu bar on top (I'm sure you have seen these
already, even on non-.NET code).
in .NET 2.0 and up it gets rejected by default; you must set it up in such a way that
all controls get handled completely by the thread that created them, often called "the UI
thread" or "the main thread".
For some simple examples, look at either one of my articles.
Luc Pattyn
|
|
|
|
|
I need to Mime encode a jpeg to stick it in a database that is normally used by an ASP app so it stores the MimeType and MimeString. I'm writing a winforms app. Everything I've found so far encodes into a mailmessage or http stream but I can't see a way of getting the data back out
Any help would be greatly appreciated.
Thanks,
Russell
|
|
|
|
|
i wnat now whether javascript can be used by asp controls
or not
i have many validations to be done on client side and need to carry them to cs file what should i do....
for this
thanking u
|
|
|
|
|
use the attribute Runat = Server in all the controls if you want to carry them to CS file.
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
thanks a lot dude....
bye
|
|
|
|
|
I am facing a very rigid problem. Project requirement is to integrate NUNIT with Crystal Reports and then write NUNIT Test cases for each Crystal reports designed... Please help me in integrating NUNIT with Crystal Reports And afterwards in writing NUNITs for the same
Harshal M Nemade
|
|
|
|
|
Hello,
Is there a way to detect that the pc monitor is going in standby mode in C# 2.0 with windows XP.
I have tried to detect WM_POWERBROADCAST and registerPowerNotifications (Vista only feature so it didn't work). Thanks for any suggestions .
|
|
|
|
|
When I was at the Detroit launch event in the developer track, the presenters said that their was no way to tell of different power setting changes in Windows XP. They did however mention the WM_POWERBROADCAST event for Windows Vista and how it could be used within gadgets/applications.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
We need to validate an expression which contains all the arithematic operators, conditional operators, logical operators, grouping such as '()' and '{}'
For example:
A+B = 10 AND (B*C)/d = 56
Thanks in advance
|
|
|
|
|
This sounds very much like homework to me, but I might be wrong...
Internet - the worlds biggest dictionary
|
|
|
|
|
hi, can anyone help me how to set up DirectSound buffer notification points? im trying to use a streaming buffer and i wanted to set notification points to know if the buffer is almost full..
mumwei
|
|
|
|
|
Hello Friends,
I want to implement socket client project.
I want only one server and any number of clients.
Please suggest me something which will work faster.
Is it possible to communicate on same port.
Please help me fast.
Thanks in Advance.
Rahul Kulkarni
|
|
|
|
|
RahulRKulkarni wrote: Please suggest me something which will work faster.
Faster than sockets? Everything will go through a Socket eventually so you are already at the lowest level of abstraction for an application. If you want to get really down and dirty you could write an NDIS driver and manipulate the packets directly as they pass through your network card.
I would like to suggest that sockets are probably not your problem. Perhaps they way you are interacting with sockets is the problem. Perhaps the protocol you invented to sit on top of TCP/IP is inefficient.
RahulRKulkarni wrote: Is it possible to communicate on same port.
The client and server will have their own ports. The server will listen on the same port for all clients. What port the client receives data on can be the same or different. If one client machine can open several connections then the client will have to use several ports.
|
|
|
|
|
Hi,
I want to know how to display the files on the web page that is uploaded for downloading later one by one.Each of this file should be password protected.Can I use data grid?Can you please give the coding.The coding is to be in C#.And the db is MS-Access.Very Urgent.........
-- modified at 1:53 Friday 16th February, 2007
Regards,
Sharon.A.
|
|
|
|
|
i am currently trying to create a program that takes screen coordinates on a panel and on click stores that information in memory then continues the line from the last click. Basically creating a polyline.
I have been looking thru the forums and got these snippets of code:
mark1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Mark_MouseUp);
mark1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Mark_MouseDown);
mark1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Mark_MouseMove);
I ran the entire source that contained the above snippets and they produced effects similar to what i want.
So can anyone give advice on what to do or where i can go for source code similar to what i want?
oh btw the above snippet came from Drawing and Editing Lines with GDI+
By Butch.er. somewhere on this site.
ghost_uwi
|
|
|
|
|
I did this yesterday, apologies if i missed any snippets
Instance variables:
LinkedList<LinkedList<Point>> _lineDrawings = new LinkedList<LinkedList<Point>>();
LinkedList<Point> _currentDrawing;
Mousedown:
_currentDrawing = new LinkedList<Point>();
_lineDrawings.AddLast(_currentDrawing);
MouseMove:
if ((e.Button & MouseButtons.Left) > 0)
{
_currentDrawing.AddLast(new Point(e.X, e.Y));
}
Paint Method:
foreach (LinkedList<Point> pointList in _lineDrawings)
{
if (pointList.Count != 0)
{
Point LastPoint = pointList.First.Value;
foreach (Point point in pointList)
{
e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red)), LastPoint, point);
LastPoint = point;
}
}
}
Undo Method:
_lineDrawings.RemoveLast();
pctMainView.Invalidate();
Hope there's something in there to help you
Russell
PS sorry about the formatting, i don't seem to be able to get generics working without ticking the ignore HTML tags tickbox
-- modified at 3:39 Friday 16th February, 2007
|
|
|
|
|
I've just realised that when i read your post the first time I missed the bit about poly line. Unfortunately i don't have any code to do that but i'll take a stab at some ideas.
Create a line struct with a start and end point as properties.
Create an instance variable: LinkedList<Line> _lineCollection where Line is your struct.
Create another instance variable: Line _currentLine
Create another: bool _drawing
On the first click create a line with start and end at the samepoint and assign it to _currentLine, add this object to _lineCollection, also set _drawing to true.
On move:
Check if _drawing == true
set _lineCollection.Last to the current mouse position
Invalidate the drawing surface
SecondClick set endpoint of _lineCollection.Last to the Mouseposition and create a new line as before assign to _currentline etc.
In the Paint method of the form:
use a foreach loop to go through all the lines in _lineCollection
e.Graphics.drawLine(Line.Start,Line.End)
HTH
Russ
|
|
|
|
|
Ok thx for the help but the help was a bit out of my league.
I got some source code and mainpulated it a bit.
...
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseDown);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseUp);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseMove);
...
Point ps = new Point();
Point pe = new Point();
private void Painter_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (flag_mouseclick == 0)
{
ps.X = e.X;
ps.Y = e.Y;
flag_mouseclick = 1;
}
pe = ps;
}
private void Painter_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Form thisform = (Form)sender;
Graphics g = thisform.CreateGraphics();
Pen p = new Pen(Color.Blue, 2);
g.DrawLine(p, ps, pe);
ps = new Point(e.X, e.Y);
g.Dispose();
}
protected void Painter_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
Form thisform = (Form)sender;
pe = new Point(e.X, e.Y);
}
the above works around where i wanted it to.
But thx for the help none the less.
-- modified at 11:53 Friday 16th February, 2007
|
|
|
|
|
Can the Microsoft chart control take row values as double? If so how?(Any code example). And i want to plot the row values against the coloumn values.(as the coloumns contain a pointer on the chart for the specified coloumn value).
|
|
|
|
|
I am trying to search for a text in a file from my desktop whose extension i gave as .surya (Purposely) and i am not getting the results while searching as expected. But suppose i want my windows desktop search to start recognising this file extension What am i supposed to do please. I would like to have the details please to surya.raghava@gmail.com.
Surya Raghava.S
|
|
|
|