|
These days, the main emphasis seems to be on the "newer" analysis and design tools: state diagrams; sequence diagrams; activity diagrams; etc.
I don't think any of these tools is a substitute for a plain "old" flowchart and / or decision tree when it comes to a particular piece of non-trivial logic.
A simple flowchart can help one to better understand a particular process (and how to program it).
If you're not familiar with flowcharts or decision trees (or some of the other "older" tools), you should take the time to learn about them if you are serious about programming. Even the "old" stuff can be useful in a particular situation.
|
|
|
|
|
Hi Gary,
I find your mention of "decision trees" very interesting; I have always wondered why they seem to have been "left-behind" in the last years.
I've been implementing my own decision-tree control in C#/.NET and intent to publish it here when it's "ripe."
An intellectual problem I see in implementing useful decision trees is to figure out a way to analyze the possibly numerous criteria so that you select-out the variables whose state-change has the maximum predictive power for the outcomes.
Imagine an air-fare discount decision-tree with some thirty possible variables, each having #n possible states: analysis of the possible decision matrix might lead to concluding that the most "powerful" predictive variable was the flyer's "age."
How to create an interface that assists "mere mortals" to write efficient decision-tables that are "pruned" so that the minimal effective set of rules/actions are used. That's the interesting problem, to me.
cheers, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
the problem is only a problem as loong as u dont have the solution yet;)
"Divide and conquer". Break Down the problem so much Down that u only solve 1 problem at the time.
If u have to do that solution many times, look for "loops".
But i think that every programmer has his weak points.
But u will get stronger and stronger to see what to do.
Using a editor will give u some sort of feedback, to what u are missing.
And mistacks will be made , i dont think i ever 1 shottet a solution. Allways something Little thing that i overlook.
I my self find web programming slow, so slow that i have to only do 2-3 linie before i debug. Mayby because of ininspirence but havnt find a editor for it. It just Work or it dosnt.
And it is easy just to look and twist a few linies to see the result, than to look at 15 linie, and no where to start.
So just keep learning.
It is mostly just matematik and logik.
And speeking of logic, i still get - less than and greater than (<>)the wrong way.
Best regards
jan
|
|
|
|
|
Hello,I understand Shell Sort definition but I can not understand
this C# code:
public void shellSort()
{
int inner, outer;
long temp;
int h = 1;
while(h <= nElems/3)
h = h*3 + 1;
while(h>0)
{
for(outer=h; outer<nElems; outer++)
{
temp = theArray[outer];
inner = outer;
while(inner > h-1 && theArray[inner-h] >= temp)
{
theArray[inner] = theArray[inner-h];
inner -= h;
}
theArray[inner] = temp;
}
h = (h-1) / 3;
}
}
please help me thx!
modified 2-Oct-15 4:39am.
|
|
|
|
|
The best way for you to help yourself understand this code is to create the initial Array and the required 'nElem variable, put a break-point at the start of the code, and then run the program, single-stepping (using F11 in Visual Studio) through the code, and observing what happens with each step. Hover the mouse over the variables and inspect their current values.
As you study what is happening in the code, take breaks, and go back and read about how the Shell sort "works." Then observe/study the running code again.
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
The answer hasn't changed since you posted exactly the same message[^] yesterday.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Message Removed
modified 2-Oct-15 4:40am.
|
|
|
|
|
I have a table in a database containing a number of records. The records have an ID number i.e. H1, H2, H3. Each record also contains a field called C1 which contains a value.
There can be multiple records with the same ID.
I want to read all the values of fields C1 for records with the ID H1 into an array. I don't know exactly how many records there are with the ID H1.
I don't want to do this in SQL.
Does anyone know how I would create a collection holding the values?
|
|
|
|
|
Read the data from the Db using a trivial SELECT:
SELECT C1 FROM MyTable WHERE ID='H1'
You can read the values using a DataReader, or a DataAdapter - whichever you are comfortable with.
For a reader, it's really simple:
List<MyTypeOfData> collection = new List<MyTypeOfData>();
while (myReader.Read())
{
collection.Add((MyTypeOfData) myReader["C1"]);
}
For an adapter, just use the table data in a Linq query:
var collection = myDataTable.AsEnumerable().Select(row => (MyTypeOfData) row["C1"]);
[edit]forgot the brackets... [/edit]
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks for the reply OriginalGriff.
What i want to do is add together all the values for each occurence of C1 and then to write this to a field.
Can I do this with what you have suggested?
|
|
|
|
|
To add them together (assuming they are numeric), you don't even need a collection:
SELECT SUM(C1) FROM MyTable WHERE ID = 'H1'
Will return the total for you - and you can use ExecuteScalar to fetch the value directly without a reader or adapter.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I want to do this through C# though
|
|
|
|
|
The just add the collection items together!
Use a foreach loop, or even a Linq method:
var sum = collection.Sum(item => item);
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Linq Method Would probably be the best as I have to write it out to a field.
I'll put together some code and see what you think?
|
|
|
|
|
Sounds good!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Im trying to do something like this:
var complexQuery = from e in orgContext.CreateQuery("Eval")
join c in orgContext.CreateQuery("Contract")
on e["contractid"] equals c["contractnameid"]
I want to do a Count of the complexQuery and whatever the count is I want to add this to a variable so I can write this out to a field.
|
|
|
|
|
Um...you do realize that a Collection has a Count method?[^]
So to get all the elements in your total sequence:
var complexQuery = from e in orgContext.CreateQuery("Eval")
join c in orgContext.CreateQuery("Contract")
on e["contractid"] equals c["contractnameid"];
int count = complexQuery.Count();
If you are trying to get the count of elements with matching ids (i.e. a collection of counts) then just Group the linq query and select the count of each group.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks for your help Ill try this.
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It sounds to me like you're looking at having a Dictionary of Dictionaries like this:
private Dictionary<string, Dictionary<string, ClassRepresentingOtherItems>> dictionary = new Dictionary<string, Dictionary<string, ClassRepresentingOtherItems>>();
public void Add(string id, string fieldValue, ClassRepresentingOtherItems items)
{
if (!dictionary.ContainsKey(id))
{
Dictionary<string, ClassRepresentingOtherItems> childDictionary = new Dictionary<string, ClassRepresentingOtherItems>();
dictionary.Add(id, childDictionary);
}
dictionary[id].Values.Add(fieldValue, items);
} This allows you to associate many fields with the same ID.
|
|
|
|
|
I have no code written yet as I'm just looking for ideas.
I am just reading the values in a field in records in a database table.
There are multiple records with the value H1 and I want to get each value C1 in each record with ID H1. And then I would count the number of occurences of C1 from the records with ID H1.
I am looking how to do this using C#
|
|
|
|
|
macca24 wrote: I don't want to do this in SQL.
Why not?
If the set is small, like say less than 100,000 than a query each time is likely to be best.
If the set is large, like 10 billion, then dragging all of the records across the wire probably isn't a good idea. Which suggests you basic assumption of a solution is wrong and again SQL would probably be better for a real solution.
|
|
|
|
|
It is only for a very small number of records around 50-100.
|
|
|
|
|
Then as I suggested - do the query.
|
|
|
|
|
I have to create PDF file in c#. The constrain is that I should not use assemblies (Ex. pdfSharp, itextSharp). The PDF file should be created by using StreamWriter class. If anyone knows the answer, please help me.
|
|
|
|