Deprecated Garbage Collections – Kenny Lee Chee Wei

A truckload of garbage by Kenny Lee Chee Wei

Archive for September 2007

Postgres – Grant privileges to all tables in a database

with 5 comments

Grant privileges to all tables in a database (select, update, insert, delete)

Eg:( Creating a read-only user in postgres)

For Postgres 8.*

For Postgres 7.*

–Function to grant access(select,insert,update,delete) to users

CREATE FUNCTION pg_grant(TEXT, TEXT, TEXT, TEXT)
RETURNS integer AS '
DECLARE obj record;
num integer;
BEGIN
num:=0;
FOR obj IN SELECT relname FROM pg_class c
JOIN pg_namespace ns ON (c.relnamespace = ns.oid) WHERE
relkind in (''r'',''v'',''S'') AND
nspname = $4 AND
relname LIKE $3
LOOP
EXECUTE ''GRANT '' || $2 || '' ON '' || obj.relname || '' TO '' || $1;
num := num + 1;
END LOOP;
RETURN num;
END;
' LANGUAGE plpgsql SECURITY DEFINER;

–Function to revoke access(select,insert,update,delete) from users

CREATE FUNCTION pg_revoke(TEXT, TEXT, TEXT, TEXT)
RETURNS integer AS '
DECLARE obj record;
num integer;
BEGIN
num:=0;
FOR obj IN SELECT relname FROM pg_class c
JOIN pg_namespace ns ON (c.relnamespace = ns.oid) WHERE
relkind in (''r'',''v'',''S'') AND
nspname = $4 AND
relname LIKE $3
LOOP
EXECUTE ''REVOKE '' || $2 || '' ON '' || obj.relname || '' FROM '' || $1;
num := num + 1;
END LOOP;
RETURN num;
END;
' LANGUAGE plpgsql SECURITY DEFINER;

–Create users for your database

CREATE USER userreadonly WITH PASSWORD 'userr3ad0nly';
CREATE USER userall WITH PASSWORD 'usersh0pa11';

–Grant respective access to users

select pg_grant('
userreadonly ','select','%','public');
select pg_grant('
userall ','select,insert,update,delete','%','public');

You might need to create lang for plpgsql if you had not done so

createlang plpgsql yrdatabasename

Written by kennii

September 21, 2007 at 2:50 am

Posted in Database, Postgres

UML Class Relationships

leave a comment »

Multiplicities

  • any number (0 or more): *
  • one or more: 1..*
  • zero or one: 0..1
  • exactly one: 1

Generalization
UML Class Diagram - Generalization

Interface
UML Class Diagram - Inheritance

Association(Aggregation, Composition)
UML Class Diagram - Association

Both are ways of designating or grouping items by relationship. In the case of composition, if the links that bind the objects are broken, then all objects are destroyed. In aggregation, it’s a looser grouping, and if the links are broken the original objects still exist.

“Aggregation differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true. For example, a company owns various departments (e.g., sales), and each department has a number of employees. If the university closes, the departments will no longer exist, but the professors in those departments will continue to exist. Therefore, a Company can be seen as a composition of departments, whereas departments have an aggregation of employees. In addition, an Employee could work in more than one department, but a department could not be part of more than one company.”

Written by kennii

September 3, 2007 at 2:56 pm

Posted in Software Design, UML

Time to abandon the Waterfall SDLC and/or Business Analysts?

with one comment

Part 1 – Abandon Waterfall SDLC?

I feel gone are the days whereby software companies should force customers to sign off system requirements.

Reason? There is no guarantee that the requirements gathered during the “System Analysis” phase of the Waterfall cycle is fully complete. So if you’re forcing the customer to sign off and get ready to accept something that they might not fully embrace after delivering, then there might be a problem late on.

Instead of contract disputes in the end, why not have constant customer collarboration/communication throught the lifecycle through an agile development methodology like Extreme Programming or Scrum? Customer should be as involved with the success of the project as the project development team.

Your company is foolish not to tap on the customer’s feedback during the project development. At the end of the day, it’s the customer who mark the acceptance tests.

Part 2- Abandon Business Analysts?

This one is abit controversial. Did i meant let the developers take over the job of business analysts? Possible, why not? Developers are supposed to be smarter than BAs, although BAs generally have better communication skills. Generally developers create prototypes anyway, so if there is any mis-communication, changes can be done swiftly.

The key problem is having good communication skills alone does not allow a BA to analyst customer IT problems and churn out technical user requirements/specifications.

It is easier to find a developer with decent communication skills than a sound business analyst with development background or is IT-savvy. And if you ever find one, do whatever it takes to keep him/her. My working experience also made me believe that BAs should come from a technical background. It improves the specs they write, trust me.

Even though generally managers prefer decision-biding employees rather than employees whom speak up and challenge decisions, you can be sure you’ll get more of those if you have such developers. “Can’t these developers just write the damn code” they thought. I’m one of those. CTOs doesn’t scare me 1 bit.

I generally prefer to gather requirements directly from customers. If information gets filtered by BAs, 100% customer requirement accuracy might just be left 80%. If specifications are written incorrectly, you are left with maybe 60%.

XP suggests that a customer be placed at the development site, Thoughtworks practises placing the development team within the customer’s site, with the latter sounding more practical to me. Simply having a key customer decision maker’s MSN account would be fine for me though.

Written by kennii

September 2, 2007 at 12:10 pm

Posted in Software Dev