|
I agree with you particularly in the case of entity modelling/persistence frameworks. The way someone else thought you should do something is almost never exactly how you have actually done it, particularly if you come in at the point where there already is a database (possibly many years old).
I've had fun fighting NHibernate on a previous project where the database predated the mappings, and in a couple of cases I gave up and just used a direct SQL query because it was much quicker and easier to do so.
In another recent project, which was very short, I wrote a simple entity persistence framework because it was much easier to do that than to work out how to make Entity Framework actually do what we wanted.
Frameworks work really well if you agree at the start that you're going to do things their way. Often that's not possible and, particularly with database mapping but to a lesser extent with every situation, the framework is too hard to adapt to a different situation.
There are a few hard problems out there for which a framework is a timesaver. UI is the obvious big one, and serving content over HTTP is another one. Web services would come in this category too. It's not worth rewriting these, because to do so, even for the limited scope of a single project, would take weeks. But in the case of entity mapping, implementing what you need for your project will probably take a few days, and that's likely to be less time than you'd waste trying to get an existing framework to play nicely with the rest of your code and with your database.
|
|
|
|
|
BobJanova wrote: There are a few hard problems out there for which a framework is a timesaver. UI
is the obvious big one, and serving content over HTTP is another one. Web
services would come in this category too. It's not worth rewriting these,
because to do so, even for the limited scope of a single project, would take
weeks
You are joking, right? Wait a second, I just need to make some new screenshots of the program I'm just working on...
Edit: You can see a bit more when you click on the images and enlarge them to full size
Screenshot 1[^]
Screenshot 2[^]
The project has four webservices, but they are of the normal .Net flavor. There also is a graphics engine for XNA. And the UI I have been working on for a while. At the moment there is no way to control what the 3D engine is doing, so the background is still a little boring. At the moment it just shows two of my first own 3D models to see that the rendering thread is still with us. The two screenshots show the first fully functional views for registering a new user and logging in.
Anyway, I must disagree with you when it comes to writing your own UI
I'm invincible, I can't be vinced
|
|
|
|
|
I should have specified, UI for normal desktop applications. UI within a graphics engine context like this is different, I just wasn't thinking along those lines when I posted before. The difference is that you want your UI to look, well, yours, whereas with a normal application you want it to look like a standard (insert OS here) application so using the standard framework gives you what you want.
I've written personal UI frameworks for games before as well, most recently in Flash (so I don't have to stick megabytes of Flex on my project just to click some buttons).
|
|
|
|
|
Well, it's not just a collection of classes that are hard coded just for this project and act like controls. It implements the interfaces of our older MVP framework, so that we can port the logic from the earlier WPF version. The views are declared with XAML and you have control over every design aspect of the controls. You can completely change the appearance and behavior of all controls from your code, in XAML or in styles and themes. By now the work on the UI has slowly shifted away from the fundamental things to adding more controls or adding more design options to existing controls.
You are right, under normal circumstances I would not have done this myself. But it was interesting to do, especially because I would never get to do it under normal circumstances. Just to think of the heart attack my boss would get if I ever proposed such a thing at work
What did it cost? Lot's of time. What did I gain? I learned a lot and I have a little UI that is mature enough to slowly be of use. And most of all, it's mine. I can give it away or charge insulting prices for it. And nobody in Redmond or elsewhere gets to decide when it's time to stop supporting it
I'm invincible, I can't be vinced
|
|
|
|
|
Ah, well doing things in hobby time is entirely different again. I've reinvented several wheels for the joy of working out how a wheel is put together, too. But even in a business environment it often makes sense to reinvent some frameworks – not usually UI ones, though, unless you're writing something seriously custom.
|
|
|
|
|
In this case it was just how the project evolved. It started out as ASP.Net webpages. A browser game. We could have slammed something together in short time, but that exactly was not our goal. Along the way webpages, even with all kinds of extras (like Ajax) became too limited and boring.
So we kept the entire sever components and added a webservice and a simple Windows Forms client. For this we wrote a little MVP framework and got a good performance with asynchronous webservice calls. Adding the first modest incarnation of the 3D engine to run in a WinForms control also worked reasonably well. The only problem was the somewhat ugly look of Windows Forms.
That's why we tried a WPF client. It was just a matter of porting our MVP framework to WPF and then making new Views while keeping the rest of the logic. Now we had a great UI, but getting the 3D engine to work in a WPF control turned out to be a problem. It always had performance problems or involved some ugly (and unsafe) hacks.
Turning things around and bringing the UI into the 3D application was the only way left to go. I looked at all the XNA UI projects I could find. Some were too simple, some were not really mature enough to be of any use and some were good but no longer in development. I think that writing a new one from scratch was no bad decision, at least if you really can pull that trick off. Now the appearance and performance of the client lies entirely in my hands.
Well, not entirely. My Padawan is getting ready to get his hands on the themes and styles and probably is going to redesign everything what you have seen in the screenshots. And he will probably come with millions of changes to the controls
I'm invincible, I can't be vinced
|
|
|
|
|
You have a point with some of this. I've not played with Hibernate yet, but for Entity Framework I have the feeling it works quite well when you're designing from scratch - your schema evolves to match the model.
In the real world though there are many huge legacy databases, often shared by your app and others. If there's a mismatch between models it often involves more code adapting the framework to your usage than if you'd coded a small layer to do the job.
Too much developer guidance, IMHO, ignores this factor.
|
|
|
|
|
I came across the following, working on some one else's project:
pingHost pping = new pingHost();
if (!pping.ping("www.google.com")) {
MessageBox.Show("The application is unable to connect to the internet and cannot continue.")
return;
}
So, I take it that Google IS the internet.
What's more, this app runs on a VPN and in some cases on a LAN where the server is in the same building.
I wonder how many seemingly unrelated applications, neigh, systems, will EPICALLY FAIL throughout the world the day Google dies or decides to block ICMP requests.
(Maybe that's the event the Mayans predicted for 21 December 2012?)
|
|
|
|
|
MatthysDT wrote: So, I take it that Google IS the internet.
Considering how big they've gotten over the years... it's pretty close... 
|
|
|
|
|
I thought only non-programmer check google to test their internet connection
Even I, sometimes open google to check internet cnnection,
But on the other hand, what should one code to test their internet connection....
|
|
|
|
|
Well, in a client-server application you should know the address of the server, so I'd say that's the address you need to ping, or better yet, make a socket connection to the server port.
Even if it's only SQL, if you can connect to port 433 (in most cases), you probably have connectivity. Some servers may block ICMP requests, so that's never a good option.
|
|
|
|
|
How do you differentiate between "Our server has gone boom, hoepfully our internal monitoring app has paged a sysadmin to fix it." and "Your Internet connection is busted; yell at your ISP." Testing several major internet sites is really the only way to go there since I've encountered more than a few cases where something in my/my isps networking gear went splat and Windows never got a clue.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
|
internetgetconnectedstate has always worked for me. You still have to check the availability of the resource.
"Go forth into the source" - Neal Morse
|
|
|
|
|
Someone I know *cough* *cough* once used that approach. They pinged a machine in the building. If the response was successful, the UI for the application was, ahem, altered in a particular way. A checkbox that represented a spectacularly stupid idea was renamed to "Steve mode", where the aforementioned 'Steve' created the idea.
Software Zen: delete this;
|
|
|
|
|
A reverse easter egg.. I love it
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
Sometimes you have network but not internet.
The better way to test it, is to use a well know network host or IP.
If you only want to check if you have network connection and it is good, check for a host like Google is the better choice.
Or, you can check for a Registrar, like 'registro.br' here in Brazil.
But I rely more on Google than an Registrar, 'cause I never saw and never heard someone speaking that Google was down.
|
|
|
|
|
A LAN in the same building is not the internet. Works as intended 
modified 20-Oct-19 21:02pm.
|
|
|
|
|
If the only solution is to check for a web, check for internic.net if internic.net fails then it is as good as the end of the (internet) world.
I have made a web search to the subject and there are examples taking the same approach you describe. Sure there are APIs to test for network connection.
Then again what exactly do we call Internet? (in particular with ACTA around the corner). It may be better idea to identify the ISP server address and check for that, then again there is the risk of a broken suboceanic cable or a satelite failure... although I understand that USA will probably not notice that, I'm not in USA. You could check for some national, institutional .gov website, until it got attacked with denial of service.
By the way, will that software work properly in china or under other government firewall that decides that google is no good? Allow be to doubt it (there is always the risk that another party will use that name, and "poison" the DNS... may be on government's behalf).
Talking about DNS, you could have a host files, or local DNS server that says that google is localhost, and the same goes for internic.net. Which is good, because you may want to mock Internet for testing (and survive the so claimed Maya's predictions).
The best solution is not to test for Internet, but test for what you need on Internet, for example microsoft products will check for microsoft.com, not because their developers think microsoft.com is the Internet, but because it is the part of the Internet they need to work. For the case of P2P or similar solutions don't even test, let the connection fail.
|
|
|
|
|
I seem to recall a Google blog post (though I can't find it again) that said they leave themselves open to ICMP on purpose specifically so that people can use them to test Internet Access.
Also, Microsoft uses a similar idea for the Network Connectivity Icon in Windows. See http://blog.superuser.com/2011/05/16/windows-7-network-awareness/[^]
I don't know exactly what URL Apple uses but my iPod touch does the same thing.
|
|
|
|
|
Thank you, you answered some remaining questions I still had on the topic.
|
|
|
|
|
|
I just got this from someone else's project:
internal static bool IsInternetConnected(string webSite)
{
bool flag;
string str;
try
{
if (webSite == null)
{
str = "www.google.com";
}
else
{
str = webSite;
}
webSite = str;
Dns.GetHostEntry(webSite);
flag = true;
}
catch
{
flag = false;
}
return flag;
}
I think a little more than DNS is required to check internet connectivity.
|
|
|
|
|
I have to say that just checking for one web address is pretty poor!
In order to determine if an internet end point is available, check to see if the connection is there (via Ping, or what ever) and this if the timeout (only needs to be short) fails, then try the next node that will serve the desired result. once you have run out of nodes to check then you are offline. You may wish to try again later...
There may be blips at an endpoint caused by many events (power outage, load balancers, etc) which could (and do) lead to momentary drop outs. It is just that most browsers have quite a good timeout that they "just work" and the end user notices only a slightly slower page load than some drastic moment at a data centre!
But then I could be wrong!
|
|
|
|
|
Ladies and Gentlemen!
Direct, from the wonders of Q&A (no, names, no embarrassment - although it is most definately deserved):
SqlDataAdapter dad = new SqlDataAdapter("Select * from esrdat where esrdat_date between '" + Convert.ToDateTime(dateTimePicker1.Value) + "' and '" + Convert.ToDateTime(dateTimePicker2.Value) + "'", con);
Here, for your delectation we have:
1) Take a valid DateTime
2) Use a default conversion to a string
3) Convert it back to a DateTime
4) Then pass that (converted back to a string via another default conversion) to SQL
But in the local format, rather than anything SQL is expecting, which is ISO format.
Twice.
And it's in Q&A because SQL doesn't like the date format it eventually gets passed...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|