Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
AnswerRe: Print Queue implementation by linked list class Pin
OriginalGriff14-Nov-15 1:20
mveOriginalGriff14-Nov-15 1:20 
GeneralRe: Print Queue implementation by linked list class Pin
Tridip Bhattacharjee14-Nov-15 5:12
professionalTridip Bhattacharjee14-Nov-15 5:12 
GeneralRe: Print Queue implementation by linked list class Pin
OriginalGriff14-Nov-15 5:29
mveOriginalGriff14-Nov-15 5:29 
GeneralRe: Print Queue implementation by linked list class Pin
Tridip Bhattacharjee14-Nov-15 5:22
professionalTridip Bhattacharjee14-Nov-15 5:22 
GeneralRe: Print Queue implementation by linked list class Pin
OriginalGriff14-Nov-15 5:35
mveOriginalGriff14-Nov-15 5:35 
GeneralRe: Print Queue implementation by linked list class Pin
Tridip Bhattacharjee14-Nov-15 8:27
professionalTridip Bhattacharjee14-Nov-15 8:27 
GeneralRe: Print Queue implementation by linked list class Pin
Tridip Bhattacharjee14-Nov-15 18:33
professionalTridip Bhattacharjee14-Nov-15 18:33 
GeneralRe: Print Queue implementation by linked list class Pin
OriginalGriff14-Nov-15 23:23
mveOriginalGriff14-Nov-15 23:23 
No.
From a personal POV, I wouldn't use a tail unless I really had to - it complicates things, and it far to easy to mess it up. I'd traverse the list (or actually use a Queue rather than a linked list anyway).

But...
Why are you returning a new node on Pop? What's wrong with the actual node? Why waste time creating a new one, when it may not be the same as the original in all respects?

Why do you have a public nextnode property and a setNext method? Dump the method and make the setter public as well.

If you are going to use XML comments (and it's a good idea) use them consistently: i.e. every public object should have a "proper" comment.

What happened to the abstract Document class?

Why does your test code not check for nulls? There is no point in returning null for an error if you don't check for it anywhere!

Why do it like this:
C#
content = node.document.Name + ": " + node.document.Type;
while (node.nextnode != null)
{
    node = node.nextnode;
    content += "\r\n" + node.document.Name + ": " + node.document.Type;
}
Try changing it round:
C#
while (node.nextnode != null)
{
    content += node.document.Name + ": " + node.document.Type + "\r\n";
    node = node.nextnode;
}
Or better, use a string builder:
C#
public string DisplayContents()
{
    StringBuilder content = new StringBuilder();
    Node node = head;
    while (node != null)
    {
        content.AppendFormat("{0} : {1}\n", node.document.Name, node.document.Type);
        node = node.nextnode;
    }
    return content.ToString();
}

And why is Document a part of Node? Is there a good reason? I can see why you might want them to be separate classes, but...
If Node inherited from Document that would make sense, or even if Document inherited from Node - but making it an encapsulated class feels very wrong, and complicates your code.

I'd probably make Node an abstract class, and inherit an abstract Document from that, then inherit the concrete PdfDocument and WordDocument you were using previously from there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...


modified 15-Nov-15 7:57am.

GeneralRe: Print Queue implementation by linked list class Pin
Tridip Bhattacharjee15-Nov-15 21:14
professionalTridip Bhattacharjee15-Nov-15 21:14 
GeneralRe: Print Queue implementation by linked list class PinPopular
OriginalGriff15-Nov-15 21:25
mveOriginalGriff15-Nov-15 21:25 
QuestionParallel vs Threading Pin
Ger Hayden14-Nov-15 0:22
Ger Hayden14-Nov-15 0:22 
AnswerRe: Parallel vs Threading Pin
Gerry Schmitz14-Nov-15 9:42
mveGerry Schmitz14-Nov-15 9:42 
GeneralRe: Parallel vs Threading Pin
Ger Hayden14-Nov-15 11:27
Ger Hayden14-Nov-15 11:27 
GeneralRe: Parallel vs Threading Pin
Gerry Schmitz14-Nov-15 20:29
mveGerry Schmitz14-Nov-15 20:29 
GeneralRe: Parallel vs Threading Pin
Ger Hayden15-Nov-15 9:50
Ger Hayden15-Nov-15 9:50 
GeneralRe: Parallel vs Threading Pin
Gerry Schmitz15-Nov-15 10:22
mveGerry Schmitz15-Nov-15 10:22 
GeneralRe: Parallel vs Threading Pin
Ger Hayden18-Nov-15 3:24
Ger Hayden18-Nov-15 3:24 
QuestionMoving Data from one form to another Pin
KakitaIppatsu13-Nov-15 14:45
KakitaIppatsu13-Nov-15 14:45 
AnswerRe: Moving Data from one form to another Pin
John Torjo13-Nov-15 14:51
professionalJohn Torjo13-Nov-15 14:51 
GeneralRe: Moving Data from one form to another Pin
KakitaIppatsu13-Nov-15 15:24
KakitaIppatsu13-Nov-15 15:24 
GeneralRe: Moving Data from one form to another Pin
John Torjo13-Nov-15 15:30
professionalJohn Torjo13-Nov-15 15:30 
GeneralRe: Moving Data from one form to another Pin
OriginalGriff13-Nov-15 21:43
mveOriginalGriff13-Nov-15 21:43 
GeneralRe: Moving Data from one form to another Pin
OriginalGriff13-Nov-15 21:35
mveOriginalGriff13-Nov-15 21:35 
AnswerRe: Moving Data from one form to another Pin
BillWoodruff13-Nov-15 16:26
professionalBillWoodruff13-Nov-15 16:26 
AnswerRe: Moving Data from one form to another Pin
OriginalGriff13-Nov-15 21:42
mveOriginalGriff13-Nov-15 21:42 

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.