Archive | Programming & tech RSS for this section

About design patterns

This article is about design patterns in a Obiective-C flavour but the general concepts are still valid, whatever programming language you use.

App’s history

An interesting book about apps so far and how to become a successful “Appster”

Programmins is the new math?

Read the article about this debate here

New Iphone5, nice but…

…read here how Chinese workers are treated at Foxconn! You can’t say you didn’t know it!

Do you write software?

So you have to read here pls! And then tell me what you think about it, if you agree or whatever, I’ve found myself in this position a lot of times!

About programming

I find this article quite interesting just to understand that you should learn the basics first of all, whatever you are going to do.

Post #1

Let’s start this brand new project with a nice post #1.! 🙂

Since my intent is to blog about creativity and the many ways you can express it, I would start with my favorite field, programming languages.

I’d like to share a C# project, a sort of  “userid-password manager”. I have been thinking about it many times, and now I got myself on it!

The following code exceprt is the main “Model” class:

using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

namespace ProjectRepositoryService
{

class Service
{
private string _serviceName;
private string _serviceDescription;
private string _userID;
private string _userPwd;

public Service() { }

public Service(string nameService, string descrService = “service description”)
{
ServiceName = nameService;
}
public Service(string nameService, string userID, string userPwd)
: this(nameService)
{

UserID = userID;
UserPassword = userPwd;
}

public string ServiceName
{
get { return _serviceName; }
set
{

if (value == null)
{
throw new ArgumentNullException();
}
else
{

value = value.Trim();
if (value.Equals(“”))
{
throw new ArgumentException(“Service name cannot be blank”);

}
else
{
_serviceName = value;
}

}

}
}

public string ServiceDescription
{
get { return _serviceDescription; }

set { _serviceDescription = value; }

}

public string UserID
{
get { return _userID; }
set
{
if (value == null)
{
throw new ArgumentNullException();
}
else
{

value = value.Trim();
if (value.Equals(“”))
{
throw new ArgumentException(“User id cannot be blank”);

}
else
{
_userID = value;
}

}

}
}

public string UserPassword
{
get { return _userPwd; }

set
{
if (value == null)
{
throw new ArgumentNullException();
}
else
{

value = value.Trim();
if (value.Equals(“”))
{
throw new ArgumentException(“User id cannot be blank”);

}
else
{
_userPwd = value;
}

}

}
}
}

class DataStorage
{

private const string storeFileName=”c:\\service.dat”;

public static void Store(Service service)
{
//recupera i dati da un file

try
{

FileStream io = new FileStream(storeFileName,FileMode.Append);
StreamWriter writer = new StreamWriter(io);
writer.WriteLine(service.ServiceName);
writer.WriteLine(service.ServiceDescription);
writer.WriteLine(service.UserID);
writer.WriteLine(service.UserPassword);
writer.Close();

}
catch (System.NotSupportedException e)
{

throw;
}catch(Exception e){
throw;

} finally{

}

}

public static Service Load(string path)
{
Service service = new Service();

return service;
}

public static ListLoadLista(string path)
{
List lista = new List();

return lista;
}
}
}

As you can see it,I’m still working on it !) New methods soon to come and to implement!