Often students from initial semester ask me how do we store our data in our programming project? When students join university to learn about computer science and technology they are usually taught programming first in courses like introduction to programming. As part of coursework students are required to work on a project. Majority of the projects, in fact almost all projects involve data handling and that data needs to be stored somewhere.
Problem students face
As a novice students don’t know how to store data. One option is to store data in plain text files if filing is taught to them but in that case their project becomes too complex for them. In my opinion, file formats is an advanced topic for students that have just started learning how to program. So, students get stuck where and how to store data. They create variables and arrays to store data in memory but that is not very useful until they have option to store their data somewhere permanently that they can retrieve later. Otherwise, every time they run their project they have to feed data from the beginning.
Teach Database before Programming
If universities modify their courses and add database in first semester and replace programming course with it then it would be easier for students to get started in computer science degree. Introduction to database is relatively easier course then programming and students will know what is database, how to store data in database, and how to retrieve it later using SQL. Then in next semester if they do a programming course then it will require only one lecture to teach them how to access database from your code and how to store and retrieve data. That will not only make their projects more valuable but will make more sense to them and they can take it to advance level in forthcoming courses.
What is your opinion? Please, let me know in the comments.
Often when designing websites static or dynamic, PHP or ASP.Net, Laravel or WordPress, you have to design in a way if user hovers an image it gets changed and an alternate image is displayed. This can be easily achieved via simple HTML events. Here is the trick:
Microsoft has announced that Visual Studio 2017 will be available for download on Tuesday, March 7, 2017. Microsoft is also celebrating a launch event. You can join at 8:00 AM PST on March 7th and 8th for a two-day online event celebrating the launch Visual Studio 2017 and the 20-year anniversary of Visual Studio.
Let’s see what comes with newer version of Visual Studio 2017.
If you’ve been developing ASP.Net MVC apps lately you might be thinking some online or cloud based app hosting platform available as PaaS for Microsoft technologies specially for hosting ASP.Net MVC apps just like OpenShift, Heroku and other platforms are available for technologies like Ruby, Python, PHP, Node.js and even supporting CMS like WordPress. The good news for ASP.Net developers is that there is a PaaS platform available which you might already know. The platform is AppHarbor. AppHarbor runs over Amazon AWS and has some nice features that I won’t go into the details of. If you are interested in knowing how AppHarbor works you can see their page here.
Regardless of AppHarbor provides a decent service, new developers might still face some difficulty in deploying their applications to AppHarbor. Specially, if you are developing apps based on new Visual Studio 2015 templates like MVC. Their are different ways to deploy but I would follow below approach which in my opinion is good and provide auto deployment or in other words Continuous Integration (CI).
What you need?
We will be using following tools and accounts.
Visual Studio 2015 (any edition, I used Professional version)
ASP.Net MVC app created from VS2015 MVC template
GitHub repo for the app/project
Local git repo for app with remote repo set as your GitHub app repo
What’s not covered?
Our focus today is deployment of our ASP.Net MVC app to AppHarbor. Therefore, we won’t be going into the details of how application is created or its architecture, what’s new in Visual Studio 2015, what is MVC, what is Git and GitHub, and how to connect your GitHub repo to AppHarbor etc. We will assume that you already have all the pre-requisites and we will just focus what problems can we come across during deployment and how to fix them.
Initialize a Git repo and connect it with your GitHub repo.
Create AppHarbor app from your GitHub repo. Whenever we commit/push our changes to our GitHub repo AppHarbor will automatically fetches the latest push and build it. Upon successful build it will deploy the app on its server otherwise it will keep last successful build. This makes things very easy.
Create an ASP.Net MVC application using Visual Studio 2015 MVC template.
Add the packages folder to .gitignore
Enable NuGet Package Restore. In VS2015 click Tools>Options and then select NuGet Package Manager and make sure both checkboxes are checked in this section.
In VS2015 right click on project and click properties, then goto Build Events tab. In the Post-build event command line text area paste the following command.
if not exist “$(WebProjectOutputDir)\bin\Roslyn” md “$(WebProjectOutputDir)\bin\Roslyn”
start /MIN xcopy /s /y /R “$(OutDir)roslyn\*.*” “$(WebProjectOutputDir)\bin\Roslyn”
Now commit and push your changes to GitHub.
That’s it! AppHarbor will automatically fetch the latest version changes and build it and you can check your AppHarbor application on its URL.
There are few things that you need to take care of specially related to security. This MVC app uses SQL Server Compact which isn’t a good option for production level apps. Secondly, your connection string or password to database must not be committed to public GitHub repo.
This post will just give you smooth start without any difficulties which I faced among other people that you can see in the resources section below.
If you think this was helpful or if I have missed anything please do let me know in the comments below.
Once upon a time, a consultant made a visit to a development project. The consultant looked at some of the code that had been written; there was a class hierarchy at the center of the system. As he wandered through the hierarchy, the consultant saw that it was rather messy. The higher level classes made certain assumptions about how the classes would work, assumptions that were embodied in inherited code. That code didn’t suit all the subclasses, however, and was overridden quite heavily. If the superclass had been modified a little, then much less overriding would have been necessary. In other places some of the intention of the superclass had not been properly understood, and behavior present in the superclass was duplicated. In yet other places several subclasses did the same thing with code that could clearly be moved up the hierarchy.
The consultant recommended to the project management that the code be looked at and cleaned up, but the project management didn’t seem enthusiastic. The code seemed to work and there were considerable schedule pressures. The managers said they would get around to it at some later point.
The consultant had also shown the programmers who had worked on the hierarchy what was
going on. The programmers were keen and saw the problem. They knew that it wasn’t really their fault; sometimes a new pair of eyes are needed to spot the problem. So the programmers spent a day or two cleaning up the hierarchy. When they were finished, the programmers had removed half the code in the hierarchy without reducing its functionality. They were pleased with the result and found that it became quicker and easier both to add new classes to the hierarchy and to use the classes in the rest of the system.
The project management was not pleased. Schedules were tight and there was a lot of work to
do. These two programmers had spent two days doing work that had done nothing to add the
many features the system had to deliver in a few months time. The old code had worked just fine. So the design was a bit more “pure” a bit more “clean.” The project had to ship code that worked, not code that would please an academic. The consultant suggested that this cleaning up be done on other central parts of the system. Such an activity might halt the project for a week or two. All this activity was devoted to making the code look better, not to making it do anything that it didn’t already do.
How do you feel about this story? Do you think the consultant was right to suggest further clean
up? Or do you follow that old engineering adage, “if it works, don’t fix it”?
Six months later the project failed, in large part because the code was too complex to debug or to tune to acceptable performance. The consultant was brought in to restart the project, an exercise that involved rewriting almost the whole system from scratch. He did several things differently, but one of the most important was to insist on continuous cleaning up of the code using refactoring.
This is an excerpt from the book preface “Refactoring – by Martin Fowler”.
The WordPress.com stats helper monkeys prepared a 2013 annual report for this blog.
Here’s an excerpt:
The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 37,000 times in 2013. If it were a concert at Sydney Opera House, it would take about 14 sold-out performances for that many people to see it.
Xdebug is a very popular PHP extension that helps with debugging and profiling of PHP scripts by providing a lot of valuable debug information. Microsoft WebMatrix is a development tool for building web applications. When WebMatrix is used to build or modify a PHP-based web application the debugging tasks can be greatly simplified if Xdebug extension is used. This post explains how to install and use Xdebug extension with WebMatrix.
Step 1: Enable PHP in WebMatrix from the site “Settings” page:
Note that if you installed any of the PHP applications from the Application Gallery then PHP will be automatically enabled.
Step 2: Download the appropriate build of Xdebug extension from downloads page. If your site uses PHP 5.2 then download “5.2 VC6 Non-thread safe (32 bit)”. If your site uses PHP 5.3 then download “5.3 VC9 Non-thread safe (32 bit)”. Use 32 bit build even if your Windows OS is 64 bit.
Step 3: Install the extension by copying the downloaded file to the following locations:
For PHP 5.2 on Windows 32 bit:
C:\Program Files\IIS Express\PHP\v5.2\ext\
For PHP 5.3 on Windows 64 bit:
C:\Program Files (x86)\IIS Express\PHP\v5.3\ext\
For PHP 5.3 on Windows 32 bit:
C:\Program Files\IIS Express\PHP\v5.3\ext\
Step 4: Open the php.ini file located in the PHP installation folder, e.g.
C:\Program Files\IIS Express\PHP\v5.2\php.ini and append the following at the end (make sure that the absolute path is correct for your version of PHP and Windows.):
Step 5: Configure PHP to display errors by changing these PHP settings in php.ini file:
display_errors = On
error_reporting = E_ALL & ~E_NOTICE
Step 6: Test that extension is enabled and works by either calling a phpinfo() function from a script or by running a buggy script:
The Xdebug extension provides a lot of useful features that help with debugging of PHP applications. You can learn more about them from the Xdebug documentation. For example you can use it to profile a PHP application. Just change the php.ini file as shown below and then make a request to a PHP script: