|
I cannot tell you what you would enjoy, but I would suggest that C or C++ would be the most useful in the areas that you are interested in.
|
|
|
|
|
Hello,
Thanks for the advice! I’ll focus on mastering one language before branching out to others. I appreciate the guidance.
|
|
|
|
|
I'm considering developing an app (iOS) my customers can use to send me files (typically PDF but could be other types, couple of MB at most). Sending the file has to be simple, just select and click Send. There are may ways to send/submit the file, e.g. (in no particular order):
- E-mail
- Dropbox (or similar)
- FTP
- Web service
- Some horrible custom client/server contraption
The files aren't top secret stuff and it's not the end of the world if the sending fails but but reliability is more important than security and simplicity (on both ends) is a must. I need to be able to group the files I receive by sender.
Any thoughts on what's the best approach?
|
|
|
|
|
When writing software, whether desktop or web-based, I have always separated the view from the view model. For example, in WPF (Microsoft desktop technology), I used MVVM, kept the XAML view as light as possible and put the logic and data access into a separate view model (regular C# class).
One of the main advantages of this is that it makes the view model easy to unit test, as I can set up mock dependencies, set the public properties that would normally be set by dependency injection or property binding and then call methods no the view model to test the code.
Nowadays I do pretty much everything in Blazor server-side, and used the same approach. My .razor file is pure markup, the .razor.cs file usually only contains overloads for the component life-cycle events, and generally passes the request through to the view model (as above).
However, one of my co-workers is encouraging the team to put all code into the .razor.cs file, and use bUnit to unit test the components. Given that we can mock dependencies, set public parameters and call methods, it does look as if this gives all the benefits of a separate view model, without needing the extra file.
Anyone any thoughts as to the advantages or disadvantages of either approach? Thanks
|
|
|
|
|
The whole "view model thing" started with the idea "visual designers" would do views; and "programmers" would do "models"; that "connected" to the view "transparently"; through the magic of "binding"; ignoring that the binding has to understand both; so that there is no "real" separation; and one bleeds into the other; without "seeing" it.
The average life of an app is 5 years. Few run on "so many" platforms that it needs sparate "views" and separate "models" in order to run.
The path of least resistance is not MVVM.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Thanks for the reply, but I'm not sure I agree with you on quite a few points.
View models (in the general sense of any MV* patterns) first came to the public attention in 1979 with Smalltalk, whereas the first visual designers for software development weren't until at least a decade later. Visual Basic was probably the first real visual designer, but didn't came out until 1991. Even if you want to stretch the point and include things like Hypercard, you only get a few more years (1987), still well after view models.
My understanding is that the point of view models was to separate the data access, logic and models from the UI. Yes, this was partly to allow the two to be developed independently, and possibly by different teams, but also (and possibly more importantly) to allow the former to be unit tested, something that was impossible in the early days of UI, and is still not so easy.
However, I don't really see the relevance. The idea of separating code into separate units is still useful, and binding is merely the common agreement between them. It doesn't really imply any bleeding going on. The view model can expose properties to be bound, and it's up to the view to choose whether or not to bind to them. That's not such a strong dependency.
Finally, even assuming your estimate of the average age of an app to be correct (which I would dispute, as I still maintain several projects that have been active for 10, 15 and in one case 25 years), why is that relevant? Length of life is not generally a determining factor in how you structure your projects, and separating layers is not just for multiple platforms.
Don't mean to be rude, but I really don't see how any of your points address my question. Please feel free to clarify if I've missed something.
|
|
|
|
|
I've seem enough questions on "how do I ... in MVVM" to know that it is (mostly) just another albatross.
Other than familiar "CRUD" LOB applictions, MVVM tends to over-complicate things: to the point that development takes longer and desirable features aren't implemented because "they" cannot figure out how to do it without "code behind" (and therefore "breaking" MVVM "rules").
MVVM is a recipe for mediocre software and budget and time overruns.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
OK, I guess our experiences are obviously very different. I find MVVM a fantastic way of keeping the concerns separate, and the ease of unit testing has improved both speed of development and ease of fixing bugs significantly. I've never, ever not implemented something because MVVM got in the way.
To me, MVVM is a recipe for faster and more stable development. As I said, I guess it depends on your experience.
Thanks anyway
|
|
|
|
|
Mr Yossu wrote: one of my co-workers is encouraging the team to put all code into the .razor.cs file
So a single file.
Unless the application is very small or there is zero functionality in that code then no that is a bad idea.
And maybe even for the second it still might not be a good idea.
Since presumably the file is modified by humans (not generated) then obviously the line count is a good demarcation. Is it going to be 100,000 lines long? Now? Or in the next 5 years then absolutely not.
If it is 20 lines long now and will be at most 100 in 5 years then it doesn't matter.
|
|
|
|
|
You might want to post your question in the forum at the bottom of the article. As it is right now, nobody has any clue what you're talking about.
|
|
|
|
|
"Sports" "Toto" "tv" (dot) "com"?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Yeah, I didn't even look at the name.
|
|
|
|
|
I am familiar with Excel VBA but new to C# and Visual Basicvisula Studio. I have an Excel file (.xlsm) with several sheets. Using ExcelDataReader, I managed to build a solution to show all sheet names in a combobox control.
I need help in how can I import the selected sheet content in combobox (cboSheet) to the datagridview1
using ExcelDataReader;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
namespace ReadandImportsheet1
{
public partial class Form1 : Form
{
private readonly object con;
public object Break { get; private set; }
public Form1()
{
InitializeComponent();
}
public Form1(object con)
{
this.con = con;
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fil = new OpenFileDialog();
fil.ShowDialog();
string path = fil.FileName.ToString();
ExcelFileReader(path);
}
public void ExcelFileReader(string path)
{
var stream = File.Open(path, FileMode.Open, FileAccess.Read);
var reader = ExcelReaderFactory.CreateReader(stream);
var result = reader.AsDataSet();
var tables = result.Tables;
foreach (DataTable table in tables)
{
cboSheet.Items.Add(table.TableName);
}
}
private void cboSheet_SelectedIndexChanged(object sender, EventArgs e)
{
string table_name = cboSheet.Text;
SqlConnection Con = new SqlConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = path; Extended Properties = "Excel 8.0; HDR = YES";");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from " + table_name + " ", con);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.DataBind();
con.Close();
}
}
} I am using Win 11 and Visual Studio 2019 with ExcelDataReader and Exceldatareader.Dataset
Any help in coding will be extremely appreciated as I am new to C# coding and can not get sheet contents into the datagridview control.
modified 23-Feb-24 1:23am.
|
|
|
|
|
Export the Excel as CSV. Then you can see what you're getting the "easy" way.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I am familiar with Excel VBA but new to C# and Visual Basicvisula Studio.
|
|
|
|
|
Well aren't you just the most delightful ...
|
|
|
|
|
Let's say you need to find the top 100 best-selling books out of a list of a million books.
What is the appropriate algorithm?
I thought it would be QuickSelect, but that only chooses one item.
Thank you.
|
|
|
|
|
You first need the list sorted in order.
|
|
|
|
|
If you don't want to sort the list, for whatever reason, you could always use a Max Heap structure with a heap size of 100. Iterate over your books and, if the new book has higher sales than a book in the heap, replace the bottom element with the new one. This assumes that no two book sales are going to be the same, so you would have to consider that particular wrinkle. In .NET for instance, you can use the PriorityQueue class to handle max heaps.
|
|
|
|
|
Let's say you don't want to use a SQL database, but you want to create a user data system for a web-based e-mail service.
You want to store the following data about each user:
username
password
address
alternate email address
phone number
What kind of data structure should you use?
Thank you.
|
|
|
|
|
Each individual user's information would ideally be held in a class structure for processing. You then need to decide how you save that in between references, and the obvious place is a database of some sort. The latter being especially important for security and data protection.
|
|
|
|
|
mike7411 wrote: Let's say you don't want to use a SQL database, ... data structure should you use
That is phrased incorrectly or it uses the wrong terms.
You need to store (persist) data. So you need to find a solution to that problem first.
Then you need to figure out how to store data, any data, in that persistent store.
After that then you can decide how to represent the data that you want to store (the second part of what you asked.)
Some persistent store solutions. This presumes that this project is very small and will remain that way.
- You can look at NoSQL solutions like MongoDB.
- You can learn just a little bit of SQL and use SQLite.
- You could use memcached actually. Just ignore the parts about distributed. It is just another object store.
- You could use a 'ini' file. Find an appropriate library. Odd but possible I suspect.
- Write your own simple file management library.
If you are on a course of learning and have not done any file manipulation before then the last choice is going to be best.
Note that some of the above can be used for larger projects but the business domain and architecture would be used to decide that (including a standard relational database) rather than just how simple it is to use.
|
|
|
|
|
mike7411 wrote: Let's say you don't want to use a SQL database, but you want to create a user data system for I disagree with the previous answer and would like to hear why no SQL database, as that makes no sense at all.
I'm guessing that the "want" comes from a manager who considers MS SQL to be the only existing DB server and doesn't like the pricing. Well, simply use an Open Source SQL implementation. An SQL Server is not limited to the MS implementations.
They're optimized to store and retrieve (relational) data from a large store, and unless you want to implement a DAL yourself with indexing capabilities, constraints (like a primary key, alternate keys, non-empty constraints etc.), think about security and access rights, and a "Structured Query Language" to interact with your DAL, whilst free ones exist and the SQL language can be learned "for free" with books and sites dedicated to it - basically recreating a SQL server, you'd simply use the ones that already exist and cost you nothing. They will have less bugs than any new storage-layer you can come up with, and have a lot more manhours invested in them than your company can provide. Those are simply facts.
You use what is the most appropriate, effective and efficient; or would you choose to write a Operating System even, if there's an unexplained "want"?
Also, you do not store a password, you store a hashvalue of the password. Otherwise any employee with access to the system can dump a textfile with username/passwords on the internet.
mike7411 wrote: What kind of data structure should you use? A table in an SQL-capable DB server.
Treat your manager like a non-technical user; if they "want" something, it has a reason and it is not always to be taken literally. You as the technical person should find out what they exactly want, why and explain the real cost and possible alternatives. This is required as "wants" and "needs" are not the same thing, and involve "costs" that a non-techie might not see. Why would anyone NOT want a FREE DAL that's well tested, well documented, in favor of creating their own?
While I'm at it, one of the columns is called "alternate email address", implying that "address" isn't an "address" but an email-address. Be specific, it makes it much more clear what you mean and removes confusion. Alternate email-address are usually not stored. Also, since you mention it is for an email-server I'd expect a table with messages, referencing that little structure you mentioned using the PK (prolly username) and another table with "attachments" stored that holds a reference to which message it is part of.
Aw, and if you really must explain this to a non-tech person, then take your time to rephrase it to be less blunt than I am in this post. Good luck with your adventure
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
(Odd - quote button is not working anywhere for me.)
My supposition for why they don't want to use SQL is because it is just one person messing around. So they don't want to learn it. In that case it will never be a real project.
|
|
|
|
|
I agree. And given all his posts he seems to think he can learn how to be a developer just by asking random questions here.
|
|
|
|
|