Friday, June 17, 2011

ASP .NET MVC3 Application Structure with Code(Read Data))



The first time I learned Model-View-Controller(MVC) concept, it was very difficult to understand concept of it. However, by doing a real project I could clearly understand MVC concept. Here is an example that read data from database and show result using MVC concept in ASP .NET framework. I hope it is helpful for programmers who want to learn MVC concept.



Saturday, June 11, 2011

Web Application MVC Project Structure in ASP .NET


App_Data : Physical data is stored
Content : CSS, images and any other static files are saved
Controllers:
Models: Classes that represent the application model for MVC Web Application are stored
Scripts :
Views :

ASP .NET MVC3 ViewBag

A ViewBag is a dynamic object that can be used to pass data from Controllers to Views as you use ViewData[]. It enables developers can use get/set values and add additional fields without strongly-typed classes. To understand this concepts, let's compare ViewData[] and ViewBag.

- Using ViewData[]
-Controller
public ActionResult Index()
{
List<string> colors = new List<string>();
colors.Add("red");
colors.Add("green");
colors.Add("blue");

ViewData["listColors"] = colors;
ViewData["dateNow"] = DateTime.Now;
ViewData["name"] = "Hajan";
ViewData["age"] = 25;

return View();
}
-Views
<p>
My name is
<b><%: ViewData["name"] %>b>,
<b><%: ViewData["age"] %>b> years old.
<br />
I like the following colors:
p>
<ul id="colors">
<% foreach (var color in ViewData["listColors"] as List<string>){ %>
<li>
<
font color="<%: color %>"><%: color %>font>
li>
<% } %>
ul>
<p>
<%: ViewData["dateNow"] %>
p>

- Using ViewBag
-Controller
public ActionResult Index()
{
List<string> colors = new List<string>();
colors.Add("red");
colors.Add("green");
colors.Add("blue");

ViewBag.ListColors = colors; //colors is List
ViewBag.DateNow = DateTime.Now;
ViewBag.Name = "Hajan";
ViewBag.Age = 25;
return View();
}
-Views
<p>
My name is
<b><%: ViewBag.Name %>b>,
<b><%: ViewBag.Age %>b> years old.
<br />
I like the following colors:
p>
<ul id="colors">

<% foreach (var color in ViewBag.ListColors) { %>
<li>
<font color="<%: color %>"><%: color %>font>
li>
<% } %>

ul>
<p>
<%: ViewBag.DateNow %>
p>

Change the body style in ASP .NET framework




the main CSS file is int the content folder and is named Site.css. To change the body style, right-click inside the body style description in the code, and click Build Sytle on the shortcut menu


Thursday, May 26, 2011

Software Requirements Specification Template and Example

Software Requirements express the needs and constraints placed on a software product that contribute to the solution of some real-world problem[ALA 04]. Software requirements that are clearly defined help software engineers to better understand the problems they will work to solve. However, defining software requirements is one of the most difficult tasks in software development. In this article, I will show software requirements specification template and example to understand what is clearly defined software requirements.

1. Introduction
1.1. purpose

- Business Goal

The business goal of the Global Personal Marketplace (GPM) system is to take advantage of the Internet and World Wide Web to radically improve the way private individuals and small companies buy and sell items.

- Buyer Business Benefits

Reference
[ALA 04]Alain Abran, Pierre Bourque, Leonard L.Tripp, Software Engineering body of Knowledge, IEEE, 2004

to be continue...

Wednesday, May 25, 2011

Blog Program File

Before we make blog program, I want to introduce files and sources. I will mention simple explanation with file name.

1. util.php
- configuration file in which functions that are used by sources are saved.
2. config.php
- Variables are saved for connecting with database.
3. global.js
- javascript files that are used by all pages.
4. blog.js
- javascript files related with blog
5. blog_main.php
- blog index main file
6. blog_create_form.php
- configuration file for creating a blog
7. blog_create_post.php
- create a blog based on a input form
8. blog_mng_form.php
- manage basic information of blog
9. blog_mng_post.php
- processing contents that are written in form
10. blog_profile
- show personal user information
11. blog_brd_mng.php
- categorize blogs that are registered
12. blog_brd_write.php
- register and modify blog that are registered
13. blog_brd_write_post.php
- processing blog contents that is written in blog category form
14. blog_write.php
- write a blog
15. blog_view.php
- view a blog
16. blog_edit.php
- edit a blog
17. blog_list.php
- view list of blogs
18. blog_tlist.php
- view all list of blogs
19. blog_write_manager.php
- Process writing, editing and removing a blog
20. blog_memo_manager.php
- Write and remove comments
21. show_image.php
- Show image if there are image files that are attached.
22. img_del.php
- Remove only attached files
23. left_menu.php
- left part of page
24. blog_main_top.html
- top part of page
25. blog_main_bt.html
- bottom part of page

Useful SQL Query

- Create Database
CREATE DATABASE database_name;

- Create Table
CREATE TABLE table_name(
column_name1 type(length) option,
column_name2 type(length) option,
.
.
);

- Insert data into table
INSERT INTO table_name (column_name1, column_name2, ...) VALUES ('value1', 'value2',...);

- Get Data
SELECT columns FROM table_name;
We can add other columns or * instead of using a column to get more data.


Create Data Base Table for a blog

When we create tables in database for saving data, we should use SQL command and syntax as below.

Syntax for creating database table
CREATE TABLE Table_Name(
Column Column_Type Optioin,
Column Column_Type Optioin,
.
.
);

Now that we have learned how to create tables in a database, Let's create tables for a blog program. You can use any other tools to create and manage tables in a database, such as MySQL Admin or NetBeans. Of course, MySQL or other DBMS should be installed correctly before we create a database and tables.
1. Member Table
- Information of member will be saved in this table.

-SQL Statements
CREATE TABLE member(
seq_num int(11) NOT NULL auto_increment,
id varchar(10) NOT NULL,
passwd varchar(10) NOT NULL,
email varchar(50) NOT NULL,
name varchar(20) NOT NULL,
phone varchar(13) NOT NULL,
reg_date datetime,
PRIMARY KEY(seq_num),
KEY id(id)
);


2. Blog List Table
- If someone register and create blog, ID, name, blog name, blog contents will be saved in this table.

-SQL statements

CREATE TABLE blog_list(
bnum int(11) NOT NULL auto_increment,
user_id varchar(12) NOT NULL,
nick_name varchar(50) NOT NULL,
blog_name varchar(100) NOT NULL,
blog_cont varchar(255),
blog_cdate date,
PRIMARY KEY(bnum),
KEY user_id_idx(user_id)
);
3. Blog_info table
- Image of blog name, profile, Information about color and all information about blog will be saved in this table except for information about blog in blog_list table

- SQL Statements
CREATE TABLE blog_info(
inum int(11) NOT NULL auto_increment,
user_id varchar(12) NOT NULL,
blog_logo char(1) DEFAULT 'N' NOT NULL,
blog_logo_ty varchar(5),
my_profile varchar(255),
title_bytype char(1) DEFAULT '1' NOT NULL,
title_bgcolor varchar(1),
title_bgimg char(1) DEFAULT 'N' NOT NULL,
title_bgimg_ty varchar(5),
box_bgcolor varchar(10),
main_img char(1) DEFAULT 'N' NOT NULL,
main_img_ty_ varchar(5),
main_text text,
main_text_bt text,
view_chk char(1) DEFAULT 'Y' NOT NULL,
PRIMARY KEY(inum)
);

4. Blog category table
- Blogs that users wrote are categorized and saved in this table.
Also, privilege to read or comment will be saved in this table.

- SQL Statements
CREATE TABLE blog_brd_list(
num int(11) NOT NULL auto_increment,
user_id varchar(12) NOT NULL,
brd_title varchar(50),
brd_pow_1 char(1) DEFAULT '3' NOT NULL,
brd_pow_2 char(2) DEFAULT '3' NOT NULL,
brd_wdate date DEFAULT '0000-00-00' NOT NULL,
PRIMARY KEY(num),
KEY user_id_idx(user_id)
);

5. blog Counter Table
- The number of people who visit a blog will be saved in this table.
- SQL Statements
CREATE TABLE blog_visit_count(
vnum int(11) NOT NULL auto_increment,
user_id varchar(12) NOT NULL,
visit_date varchar(8) NOT NULL,
visit_count int(8) DEFAULT '0' NOT NULL,
PRIMARY KEY(vnum),
KEY user_id(user_id),
KEY visit_date(visit_date)
);
6. The table for saving visitors of blog
- Users who visit a blog will be saved in this table.

- SQL Statements
CREATE TABLE blog_visit_member(
mnum int(11) NOT NULL auto_increment,
user_id varchar(12) NOT NULL,
visit_data varchar(8) NOT NULL,
visit_id varchar(12) NOT NULL,
PRIMARY KEY(mnum),
KEY user_id(user_id),
KEY visit_id(visit_id)
);

7. Blog information table for each user
- Basic information for each user will be saved in this table
The table will be created during execution dynamically

- SQL statements
CREATE TABLE bg_user id_t(
num int(6) NOT NULL auto_increment,
brd_list_fk int(11) DEFAULT '0' NOT NULL,
id_fk varchar(12) NOT NULL,
name varchar(30) NOT NULL,
title varchar(200) NOT NULL,
blog_img1 varchar(50),
contents_1 text,
blog_img2 varchar(50),
contents_2 text,
blog_img3 varchar(50),
contents_3 text,
comm_chk char(1) DEFAULT 'Y' NOT NULL,
wdate varchar(8) NOT NULL,
PRIMARY KEY(num)
);

8. The table for saving comments of blog
- All comments of blog will be saved in this table for each user.
This table will be created during execution dynamically

-SQL statements
CREATE TABLE bg_user id_ct(
cnum int(6) NOT NULL auto_increment,
num_fk int(11) DEFAULT '0' NOT NULL,
id_fk varchar(12) NOT NULL,
memo text NOT NULL,
cdate varchar(8) NOT NULL,
PRIMARY KEY(cnum)
);


Friday, May 13, 2011

Blog Program with PHP and MySQL- 2



In the previous chapter, I showed structured view of all files for a blog program. Let's start to making a blog program.
First we should have to do for making a blog program is create database table. Of course, we should analyze requirements and design system first. However, This article just focus on programing skills about PHP and MySQL, so we are going to move on implementing part directly. If I have a time later, I promise I will post other articles about software development processes, such as requirements, design, testing, maintenance and so on.
Anyway, Let's start to make blog program by crating database.
We are going to make 7 tables in a database. List of data base tables we should create are shown as below. Keep in mind that "member id" in the last two lows means each members ID. e.g, Each member will have bg_"member_id"_t and bg_"member_id"_ct. For example, There are two members. One of IDs is "hyeon" and another is "cheol". "hyeon" will have both tables, "bg_hyeon_t" and "bg_hyeon_ct". Also, "cheol" will have both tables, "bg_cheol_t", and bg_cheol_ct".


Blog Program with PHP and MySQL- 1

A blog is a type of website or part of a website. We can upload news, text, images. links to ohter blog, web pages, or anything we want.
Since today, I will make a blog program using PHP and MySQL. I hope this article will be very helpful for people who want to learn web programming using PHP and MySQL

First of all, I want to show structured view of the blog program. It shows how all files for the blog program are inter-related. This structured view is categorized as create blog, navigate blog, and manage contents and blog.










Capability Maturity Model Integration (CMMI)

Capability Maturity Model Integration (CMMI) is a process improvement approach to improve organization's performance. It was developed by Software Engineering Institute (SEI) at Carnegie Mellon University.
There five maturity level in CMMI. Each maturity level contains process areas. If an organization wants get maturity levels, it should satisfy all process areas in each maturity level. I summarized maturity level and each process areas as below. You can see a bigger picture by clicking the picture. Rectangles filled with dark blue mean process areas.



The Open Group Architecture Framework (TOGAF) -1

The Open Group Architecture Framework (TOGAF) is an EA framework developed by Open Group.
TOGAF has four architecture domains. Each architecture domain describes certain perspectives of architecture.
- Business Architecture : business strategy, governance, organization, and key business processes
- Data Architecture : the structure of an organization's logical and physical data assets and data management resources
- Application Architecture : a blueprint for the individual application systems to be deployed, their interactions, and their relationships to the core business processes or the organizations
- Technology Architecture : the logical software and hardware capabilities that are required to support the deployment of business data, and application services. It includes IT infrastructure, middle ware, networks, communications, processing, standards, etc.

TOGAF includes an iterative process that is called Architecture Development Method (ADM). It is a method for developing an EA as well as the core of TOGAF. It consists of 9 steps as below.



Enterprise Architecture

Enterprise Architecture (EA) is a rigorous description of the structure of an enterprise, which consist of enterprise components, the externally visible properties of those components, and the relationships between them. EA could be an approach for business and IT alignment. The Open Group showed advantages of EA as below.

Advantages

A more efficient IT operation

- Lower costs for software development, support, and maintenance

- Increased portability of application

- Improved interoperability and easier system and network management

- Improved ability to address critical enterprise-wide issues like security

- Easier upgrade and exchange of system components

Better return on existing investment, reduced risk for future investment

- Reduced complexity in IT infrastructure

- Maximum return on investment in existing IT infrastructure

- The flexibility to make, buy, or out-source IT solutions

- Reduced risk overall in new investment, and the costs of IT ownership

Faster, simpler, and cheaper procurement

- Buying decisions are simpler, because the information governing procurement is readily available in a coherent plan

- The procurement process is faster — maximizing procurement speed and flexibility without sacrificing architectural coherence

- The ability to procure heterogeneous, multi-vendor open systems


An EA frameworks can be used to organize the structure and views associated with an EA. There are well-known and widely used EA frameworks, such as Zachman Framework, DoDAF (Department of Defense Architecture Framework) and TOGAF(The Open Group Architecture Framework).
Among those frameworks, Zachman framework was published first in 1987. It is originally made in 1987, and then updated and renamed in 1990s. It defines and views enterprise in structured view. It consists of tow dimensional classification matrix that is based on six communication question and five structured view. A below table shows "View of Zachman Framework"

Data

(What)

Function

(How)

Network

(Where)

People

(Who)

Time

(When)

Motivation

(Why)

Scope

List of things important in business

List of Business Processes

List of Business Locations

List of Important Organizations

List of Events

List of Business goal & Strategies

Business Model

Conceptual Data/Object Model

Business Process Model

Business Logistics System

Work Flow Model

Master Schedule

Business Plan

System Model

Logical Data Model

System Architecture Model

Distributed Systems Architecture

Human Interface Architecture

Processing Structure

Business Rule Model

Technology Model

Physical Data/Class Model

Technology Design Model

Technology Architecture

Presentation Architecture

Control Structure

Rule Design

Detailed Representation

Data Definition

Program

Network Architecture

Security Architecture

Timing Definition

Rule Specification

Functioning Enterprise

Usable Data

Working Function

Usable Network

Functioning Organization

Implemented Schedule

Working Strategy


Business and IT Alignment

Business-IT alignment is a desired state in which a business organization is able to use information technology (IT) effectively to achieve business objectives. Recently, effective and efficient information technology (IT) supporting business strategies and processes are key elements for a successful company. In IT research, business and IT alignment is one of the biggest issues. Many approaches can be used for business and IT alignment. Among those are active IT portfolio management, directors' meeting, scorecard, and enterprise architecture (EA)

Wednesday, May 11, 2011

Enterprise Architecture

An enterprise architecture (EA) is a rigorous description of the structure of an enterprise, which comprises enterprise components (business entities), the externally visible properties of those components, and the relationships between them. Open Group presented advantages of EA as below.

Advantages

A more efficient IT operation

- Lower costs for software development, support, and maintenance

- Increased portability of application

- Improved interoperability and easier system and network management

- Improved ability to address critical enterprise-wide issues like security

- Easier upgrade and exchange of system components

Better return on existing investment, reduced risk for future investment

- Reduced complexity in IT infrastructure

- Maximum return on investment in existing IT infrastructure

- The flexibility to make, buy, or out-source IT solutions

- Reduced risk overall in new investment, and the costs of IT ownership

Faster, simpler, and cheaper procurement

- Buying decisions are simpler, because the information governing procurement is readily available in a coherent plan

- The procurement process is faster — maximizing procurement speed and flexibility without sacrificing architectural coherence

- The ability to procure heterogeneous, multi-vendor open systems


There are many EA frameworks that define how to organize the structure and views associated with an EA. For example, TOGAF (The Open Group Architecture Framework), DoDAF (Department of Defense Architecture Framework), Zachman Framework are well-known EA frameworks.


Tuesday, May 10, 2011

Creating Simple Scripts using JavaScript


JavaScript is a script language that can be used for web development. There are a lot of useful functions in JavaScript. We can include JavaScript commands in the HTML document, and then the script you wrote will be executed in a web browser.
There are many text editor we can use for writing Java Script. For example, Adobe Dreamweaver, TextPad, NetBeans are most popular tools for JavaScript at present. Given the choice among tools, I recommend NetBeans because of many powerful functions and free cost. After Netbeans is owned by Oracle, some functions are restricted. However, it has all functions for developing a web page using JavaScript. You can get NetBeans athttp://netbeans.org/downloads/.