Author Topic: RAWK Web Development Circle  (Read 53229 times)

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #120 on: July 13, 2008, 05:20:04 PM »
Touché!

I definitely think you should try PHP5 out. It's a revelation. I'll send you my activerecord class i've written at some point if you're interested.
Ta, but I'm not into PHP at the moment. I think it'll need another couple of versions to catch up with Ruby and Python.
Quidquid latine dictum sit, altum sonatur.

Offline Mudface_

  • Boys Pen
  • *
  • Posts: 0
Re: RAWK Web Development Circle
« Reply #121 on: July 13, 2008, 06:57:20 PM »
Thanks, Mudface. Now I get it. Do you need the abstract class/interface like in Objective-C? What purpose does it serve? Is that where you implement methods common to all subclasses? Or is it just a way of guaranteeing you don't forget to implement a method in subclasses?

Yes to the last two questions. Any class inheriting from an abstract class must also implement its abstract methods and properties.

Offline Deano06

  • Confirmed BOFH TECHNOBORE#1
  • Anny Roader
  • ****
  • Posts: 425
  • Smarter than you.
  • Super Title: Or is he?
Re: RAWK Web Development Circle
« Reply #122 on: July 14, 2008, 04:02:36 PM »
Ta, but I'm not into PHP at the moment. I think it'll need another couple of versions to catch up with Ruby and Python.

How do you mean catch up? I'd say in terms of maturity Ruby and PHP are equal. Python has some catching up the object oriented area. There's no interfaces, no true scope for methods and properties, no abstract classes, no final classes, no references/pointers.

PHP is far easier than Ruby and Python to deploy. I guess because this is my living that's more important to me.
« Last Edit: July 14, 2008, 04:07:17 PM by Deano06 »

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #123 on: July 14, 2008, 08:47:10 PM »
How do you mean catch up? I'd say in terms of maturity Ruby and PHP are equal. Python has some catching up the object oriented area. There's no interfaces, no true scope for methods and properties, no abstract classes, no final classes, no references/pointers.

PHP is far easier than Ruby and Python to deploy. I guess because this is my living that's more important to me.
I was talking in terms of OO when I said catch up.

Python is way ahead of PHP in terms of OO. No, it doesn't have interfaces. That's a design choice, not a sign of being behind. Look at the link Mudface posted regarding abstract classes and you'll see. Similarly, there is no need for pointers or references--these problems are solved in different ways. What you mean by true scope, I have no idea. Closures, perhaps? (Yes, it has them).

I've got no problem answering questions, but I'm sick of correcting your ignorant statements about Python when you have repeatedly demonstrated you haven't got the first clue about the language.
Quidquid latine dictum sit, altum sonatur.

Offline Deano06

  • Confirmed BOFH TECHNOBORE#1
  • Anny Roader
  • ****
  • Posts: 425
  • Smarter than you.
  • Super Title: Or is he?
Re: RAWK Web Development Circle
« Reply #124 on: July 14, 2008, 11:43:38 PM »
Python doesn't support true scope, Python lacks private, protected and public modifiers for properties and methods.

Abstract classes are very important for large-scale application development with multiple developers. Both Java and C++ have them I'd say they are the two most popular and important Object Oriented languages. Although I don't like Java i think it's OO model is nigh on perfect (for example no multiple inheritance, interfaces, class abstractions) and what language developers should be using as a model for standardised object oriented language design.

I'm interested to see some real-world python (or any web) projects you've worked on/deployed anyway. You seem to know some stuff. You talk the talk but do you walk the walk? :)

I just lead the complete re-design and development of Brewers (large painting and decorating retail chain). Should be soft launching start of August we'll see how it scales it's pretty heavy on db calls so I wrote a caching system into the framework which reduces load times on some pages from 0.029 seconds to 0.000002 and doesn't make any db calls. After that I'm doing a whole bunch of stuff for ninendo (minisites for DS games). I'm really excited to work on some big name projects! What's everyone else up to?

Offline Deano06

  • Confirmed BOFH TECHNOBORE#1
  • Anny Roader
  • ****
  • Posts: 425
  • Smarter than you.
  • Super Title: Or is he?
Re: RAWK Web Development Circle
« Reply #125 on: July 16, 2008, 11:50:28 AM »

I'm doing a straight forward google maps implmentation, i'm trying to overlay a div (position:absolute) on top of the google maps when its loading etc but I can't seem to get the z-index above the google map. Anyone ever come across this before?


IE:


How it should look (and does in ff, safari etc):



Any ideas?

Offline iSmiff

  • TECHNOBORE
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 18,131
Re: RAWK Web Development Circle
« Reply #126 on: July 16, 2008, 11:57:37 AM »
post a link to google maps
STFU and agree with me.

Offline Deano06

  • Confirmed BOFH TECHNOBORE#1
  • Anny Roader
  • ****
  • Posts: 425
  • Smarter than you.
  • Super Title: Or is he?
Re: RAWK Web Development Circle
« Reply #127 on: July 16, 2008, 12:03:41 PM »
no, it has to be an integration really, we've spent about £2000 on PAF data so we can integrate it properly. there's also loads of overlays with stores on etc.

Offline WheelOfCheese

  • Anny Roader
  • ****
  • Posts: 307
  • Are you my Caucasian?
Re: RAWK Web Development Circle
« Reply #128 on: July 24, 2008, 10:14:28 AM »
Not sure if this belongs in here, but I'll ask anyway.

I'm putting together a Flash movie for 4 Departments in work. I can create the Flash no probs & i'll upload it via Adobe Conrtbute.  But I was wondering if you can 'multi-link' Flash movies.

I know I can add a hyperlink to the whole thing, but is it possible for Link A to work when Department A is on screen, and when Department B comes up, a link to department B is used?

Any info would be great,

Thanks

Offline markay_stinkay

  • Believer
  • ******
  • Posts: 10,854
  • ☆☆☆☆☆☆
    • Bet £50, get £50 free
Re: RAWK Web Development Circle
« Reply #129 on: July 24, 2008, 05:48:03 PM »
"The Web Server is too busy, cannot handle any more connections."

Max connections is set to 10 and yet I get this message not long after 2 browsers are actively using the server.

Anyone have any web server experience?

Offline Ben S

  • Remember we were partners in crime. Pigeon Fancier. GTL Bus Freak. Also known as Bambi, apparently - or Miss Kitty on Wednesdays....
  • RAWK Staff.
  • Believer
  • ******
  • Posts: 32,164
  • Liverpool 5 - 1 London
Re: RAWK Web Development Circle
« Reply #130 on: July 24, 2008, 06:37:11 PM »
Each hit could be a connection, disable keep alive if you have to use so few connections.

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #131 on: July 27, 2008, 11:41:00 PM »
"The Web Server is too busy, cannot handle any more connections."

Max connections is set to 10 and yet I get this message not long after 2 browsers are actively using the server.

Anyone have any web server experience?
Most webservers can handle many hundreds of simultaneous connections. They're not actually doing anything a lot of the time. Remember, each webpage request fetches dozens of files (the HTML page, the images, CSS etc.), and most browsers are set to open 2 or 3 connections to a server at the same time, so--depending on browser configuration--each webpage request can lead to 20+ requests in total to the server.

Do what Ben S said, if you really can't go above 10, but 100 shouldn't be a problem unless you're using a Nintendo DS as your webserver.
Quidquid latine dictum sit, altum sonatur.

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #132 on: July 27, 2008, 11:49:25 PM »
Python doesn't support true scope, Python lacks private, protected and public modifiers for properties and methods.
You still haven't explained what you mean by "true scope", and as for the others, so what?

If devs don't stick to your published API, or can't be arsed to read the spec properly, that's their problem. There are plenty of other ways to shoot yourself much more emphatically in the foot than pratting about with the internals of classes you probably shouldn't.

If Python is good enough to build Yahoo! Mail and Google Mail, I don't see what your argument is. Here's an old list of some large projects built using Python:
http://mail.python.org/pipermail/python-list/2002-June/148967.html
Quidquid latine dictum sit, altum sonatur.

Offline ♠Dirty Harry♠

  • Michael Pain the tittie-fixated inflatable doll salesman
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 19,027
Re: RAWK Web Development Circle
« Reply #133 on: November 11, 2008, 06:17:08 PM »
Need a little help with this PHP script

All i want is for a redirect on error ( when the first if statement is false) to a page I have created myself (for example error.html) instead i am just getting a php page with an error (highlighted in bold), i'm guessing that the redirect code has to go here but not sure of what I have to enter to achieve the result.

If the first 'if' statement is true i want the script to go ahead and execute the other 'if' statement to submit the email

<?php

include_once("captcha.php");

if (WSP_CheckImageCode() != "OK") {
    die('You have entered the code incorrectly');
}


if(isset($_POST['submit'])) {

   $to = "info@blabla.com";
   $subject = "Information";
   $name_field = $_POST['name'];
   $email_field = $_POST['email'];
   $phone_field = $_POST['phone'];
   $info_field = $_POST['info'];
   
   $body = "Name: $name_field\n E-Mail: $email_field\n Phone: $phone_field\n Info: $info_field\n";

   echo header('Location: submit.html');
   mail($to, $subject, $body);
   
} else {
   echo "You do not have permission to access this file";
}
?>

Any help would be great cheers  :wave
« Last Edit: November 11, 2008, 06:56:04 PM by ♠Dirty Harry♠ »

Offline Ben S

  • Remember we were partners in crime. Pigeon Fancier. GTL Bus Freak. Also known as Bambi, apparently - or Miss Kitty on Wednesdays....
  • RAWK Staff.
  • Believer
  • ******
  • Posts: 32,164
  • Liverpool 5 - 1 London
Re: RAWK Web Development Circle
« Reply #134 on: November 11, 2008, 06:37:46 PM »
header('Location: http://www.example.com/');

Offline ♠Dirty Harry♠

  • Michael Pain the tittie-fixated inflatable doll salesman
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 19,027
Re: RAWK Web Development Circle
« Reply #135 on: November 11, 2008, 06:40:16 PM »
header('Location: http://www.example.com/');

Will that only execute if there is an error though? I don't want it executing when the first if statement is true because i want the next if statment to be triggered in that case

Cheers
« Last Edit: November 11, 2008, 06:43:28 PM by ♠Dirty Harry♠ »

Offline ♠Dirty Harry♠

  • Michael Pain the tittie-fixated inflatable doll salesman
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 19,027
Re: RAWK Web Development Circle
« Reply #136 on: November 11, 2008, 07:10:15 PM »
Can anyone give me an opinion on what platform would be best to begin learning now? I've been reading up on Ajax and Php and they both seem interesting, knowing they are different which has a bigger future in the industry and is more worthwile learning?


Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #137 on: November 11, 2008, 11:36:53 PM »
Will that only execute if there is an error though? I don't want it executing when the first if statement is true because i want the next if statment to be triggered in that case

Cheers
You replace your die("My error message") with header("Location: http://mydomain.com/errorpage.html")

You must call header() before ANY output to the browser or it won't work.

Can anyone give me an opinion on what platform would be best to begin learning now? I've been reading up on Ajax and Php and they both seem interesting, knowing they are different which has a bigger future in the industry and is more worthwile learning?

AJAX and PHP are not alternatives, they're complementary. PHP is purely server-side and AJAX runs on the browser AND the server. AJAX more or less requires JavaScript, but it's more of a programming model than a platform.

PHP is easy to learn, but isn't a particularly well designed language and encourages bad programming habits.
Quidquid latine dictum sit, altum sonatur.

Offline ♠Dirty Harry♠

  • Michael Pain the tittie-fixated inflatable doll salesman
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 19,027
Re: RAWK Web Development Circle
« Reply #138 on: November 12, 2008, 11:33:53 AM »
You replace your die("My error message") with header("Location: http://mydomain.com/errorpage.html")

You must call header() before ANY output to the browser or it won't work.

AJAX and PHP are not alternatives, they're complementary. PHP is purely server-side and AJAX runs on the browser AND the server. AJAX more or less requires JavaScript, but it's more of a programming model than a platform.

PHP is easy to learn, but isn't a particularly well designed language and encourages bad programming habits.

I've tried using the 'header' tag but it causes the script t process the rest of the script and to skip directly to the last 'header' which which sends the user to the successfully completed page even if they have typed the verification code in wrong.


As for the second question, do you recommend some like ASP.NET Instead of PHP?

 

Offline SP

  • Thor ain't got shit on this dude! Alpheus. SPoogle. The Equusfluminis Of RAWK. Straight in at the deep end with a tube of Vagisil. Needs to get a half-life. Needs a damned good de-frag.
  • RAWK Staff.
  • Believer
  • ******
  • Posts: 34,954
  • .
Re: RAWK Web Development Circle
« Reply #139 on: November 12, 2008, 11:46:09 AM »
I've tried using the 'header' tag but it causes the script t process the rest of the script and to skip directly to the last 'header' which which sends the user to the successfully completed page even if they have typed the verification code in wrong.


As for the second question, do you recommend some like ASP.NET Instead of PHP?

 

Call die() after the error header script to stop further processing.

<?php

include_once("captcha.php");

if (WSP_CheckImageCode() != "OK") {
    header("Location: http://mydomain.com/errorpage.html")
    die('');
}


Offline SP

  • Thor ain't got shit on this dude! Alpheus. SPoogle. The Equusfluminis Of RAWK. Straight in at the deep end with a tube of Vagisil. Needs to get a half-life. Needs a damned good de-frag.
  • RAWK Staff.
  • Believer
  • ******
  • Posts: 34,954
  • .
Re: RAWK Web Development Circle
« Reply #140 on: November 12, 2008, 11:47:28 AM »
As for the second question, do you recommend some like ASP.NET Instead of PHP?

Depends what you are doing and what your experience is. No one language is best for all jobs.

Offline ♠Dirty Harry♠

  • Michael Pain the tittie-fixated inflatable doll salesman
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 19,027
Re: RAWK Web Development Circle
« Reply #141 on: November 12, 2008, 11:59:17 AM »
Call die() after the error header script to stop further processing.

<?php

include_once("captcha.php");

if (WSP_CheckImageCode() != "OK") {
    header("Location: http://mydomain.com/errorpage.html")
    die('');
}

That worked a charm, thanks. Cheers to everyone else too


Depends what you are doing and what your experience is. No one language is best for all jobs.

It's mostly going to be used for general website navigation and shopping carts
« Last Edit: November 12, 2008, 12:05:16 PM by ♠Dirty Harry♠ »

Offline Mudface_

  • Boys Pen
  • *
  • Posts: 0
Re: RAWK Web Development Circle
« Reply #142 on: November 12, 2008, 12:07:22 PM »
As for the second question, do you recommend some like ASP.NET Instead of PHP?

wacko's a Python man.

I prefer using ASP.NET myself, but then I work for a Windows-only company so it makes sense to use it.

Offline PaulV

  • RAWK Pope
  • RAWK Supporter
  • Kopite
  • ******
  • Posts: 635
Re: RAWK Web Development Circle
« Reply #143 on: November 12, 2008, 02:44:36 PM »
As for the second question, do you recommend some like ASP.NET Instead of PHP
I am happy with PHP using a MVC framework such as CakePHP. This provides a decent structure on which to hang your PHP code and helps to reduce the complexity that can occur in some projects.
To many people have discovered "Football Manager" and now they all think they are Kenny but alas so many end up as Roy

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #144 on: November 12, 2008, 04:03:02 PM »
It's mostly going to be used for general website navigation and shopping carts
Like Mudface_ says, if you're writing exclusively for Windows (servers, not clients), you'd probably be better of with something written especially for Windows. PHP is designed for posix systems (Linux, UNIX, OS X), not Windows.

As PaulV says, it's always best to start off with a framework rather than roll your own, except for the very simplest of applications. It takes care of a lot of things for you, like sessions and logging in/out, access rights, database access, and a good framework will have the most important thing in a database-backed webapp: user input and SQL abstraction and sanity checking.
Quidquid latine dictum sit, altum sonatur.

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #145 on: November 12, 2008, 04:12:03 PM »
Had a class today with this accountant who's building a website for the brass band he plays in. As far as I can tell, his PHP+MySQL app uses one table that looks like this:

Code: [Select]
username    property    value
==================================
michael     real name   Michael
dean        real name   Dean
michael     age         54
dean        age         33
sabine      real name   Sabine
sabine      age         26
michael     join date   11/01/2008
dean        join date   03/06/2008
sabine      join date   23/02/2008
michael     email       michael@n00b.de
dean        email       dean@example.com
sabine      email       bine@schwartz.de
...
...

This allows him to add to the DB "schema" at will and he doesn't have to bother with lots of empty results where a member doesn't have a value set for a certain property. This is what PHP does to people!
Quidquid latine dictum sit, altum sonatur.

Offline Mudface_

  • Boys Pen
  • *
  • Posts: 0
Re: RAWK Web Development Circle
« Reply #146 on: November 12, 2008, 04:13:20 PM »
Jesus, that's horrendous.

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #147 on: November 12, 2008, 04:27:49 PM »
Jesus, that's horrendous.
:D

He even seems to know about normalisation, and that everyone else in the world does it a different way, but he's adamant his way is better. Apparently, this elegant solution means he doesn't have to hack his display code due to NULLs in result sets  :P
« Last Edit: November 12, 2008, 04:30:26 PM by wacko »
Quidquid latine dictum sit, altum sonatur.

Offline ♠Dirty Harry♠

  • Michael Pain the tittie-fixated inflatable doll salesman
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 19,027
Re: RAWK Web Development Circle
« Reply #148 on: November 12, 2008, 04:28:32 PM »
Like Mudface_ says, if you're writing exclusively for Windows (servers, not clients), you'd probably be better of with something written especially for Windows. PHP is designed for posix systems (Linux, UNIX, OS X), not Windows.

As PaulV says, it's always best to start off with a framework rather than roll your own, except for the very simplest of applications. It takes care of a lot of things for you, like sessions and logging in/out, access rights, database access, and a good framework will have the most important thing in a database-backed webapp: user input and SQL abstraction and sanity checking.

Well the idea is to start small and build it up, i'm not programming for anything in particular, i've done a lot of static sites and i consider myself more a designer but i just want to move to the next stage and dynamic development is the natural progression, i like to understand how things work (in other words I like to take apart stuff).

I've done a little more research and a lot of places are saying that ColdFusion is great for people (web designers) who are not used to scripting as it's more tag based or something? Any thoughts on it?

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #149 on: November 12, 2008, 04:44:32 PM »
Well the idea is to start small and build it up, i'm not programming for anything in particular, i've done a lot of static sites and i consider myself more a designer but i just want to move to the next stage and dynamic development is the natural progression, i like to understand how things work (in other words I like to take apart stuff).

I've done a little more research and a lot of places are saying that ColdFusion is great for people (web designers) who are not used to scripting as it's more tag based or something? Any thoughts on it?
I've never more than played with ColdFusion. Struck me as a right hack. It might do what you need, but it certainly won't teach you much about programming.

You're right to start small, so stay away from ecommerce, or anything containing sensitive data. Try building a script that accepts and resizes an image or similar. Check out some tutorials on the web. Follow one of those build-your-own-wiki tutorials. PHP Builder used to be a good site. I'm sure others can recommend better ones.

Web apps look easy to build, but they're not, because they need to be much more secure than desktop apps: a web-based application is by definition out there for anyone to poke with a stick, and it keeps everybody's data in one place.

Frameworks are usually pretty big and can be hard to get your head around, especially if you're just learning the language, too, but they usually take care of the dangerous stuff for you better than you could.
Quidquid latine dictum sit, altum sonatur.

Offline Craig S

  • KOP CONDUCTOR
  • Believer
  • ******
  • Posts: 3,938
Re: RAWK Web Development Circle
« Reply #150 on: November 12, 2008, 04:44:35 PM »
:D

He even seems to know about normalisation, and that everyone else in the world does it a different way, but he's adamant his way is better. Apparently, this elegant solution means he doesn't have to hack his display code due to NULLs in result sets  :P

HaHa. But he introduces loads of duplicate data in columns 1 & 2.

Does he have any relationships? (Don't mean in a physical sense, even geeks can pull!)
Would love to see his ER Diagram.

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #151 on: November 12, 2008, 06:19:51 PM »
HaHa. But he introduces loads of duplicate data in columns 1 & 2.

Does he have any relationships? (Don't mean in a physical sense, even geeks can pull!)
Would love to see his ER Diagram.
Apparently, he adds duplicate (name, property) rows to the table for one-to-many. I've no idea what he does if he needs more than one column at anything other than the top level. Probably uses "address_1_postcode", "address_1_town", "address_2_postcode", "address_2_town" etc.

It wouldn't suprise me to find next week that he's grown beyond the limits of what MySQL can achieve and has cunningly extended it by serialising the "value" column.

As far as his plan for the DB schema goes, I suspect that, being an accountant of 15 years, he has an Excel-shaped brain.
Quidquid latine dictum sit, altum sonatur.

Offline Ben S

  • Remember we were partners in crime. Pigeon Fancier. GTL Bus Freak. Also known as Bambi, apparently - or Miss Kitty on Wednesdays....
  • RAWK Staff.
  • Believer
  • ******
  • Posts: 32,164
  • Liverpool 5 - 1 London
Re: RAWK Web Development Circle
« Reply #152 on: November 12, 2008, 06:32:56 PM »
To be fair, I don't think you can blame PHP for his bad database "design".

Offline Mudface_

  • Boys Pen
  • *
  • Posts: 0
Re: RAWK Web Development Circle
« Reply #153 on: November 12, 2008, 07:15:23 PM »
Yeah, but we're gonna.

Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #154 on: November 12, 2008, 07:32:29 PM »
To be fair, I don't think you can blame PHP for his bad database "design".
Not directly, of course, but plain PHP's just-plonk-me-in-the-HTML nature encourages rotten habits. A decent framework (in any language) strongly emphasises a sane application and database design.

If he'd started with Ruby on Rails, Django etc., I don't believe he'd have ever used the DB like that.

You know what you're doing, so you know to validate user input and protect against SQL injection, and how to use a DB properly, so raw PHP is fine for you. Beginners need a framework to protect them from their own mistakes.

Plain PHP gives you all this power but no indication as to how to use it properly. It doesn't force you to think about the design of the app in the slightest before starting, and you end up bashing out a site in Dreamweaver, changing all the file extensions to .php, and going through each page copying and pasting bits of PHP here and there, reading odds and sods on php.net as you go.
Quidquid latine dictum sit, altum sonatur.

Offline main-stand-molby

  • Kopite
  • *****
  • Posts: 573
Re: RAWK Web Development Circle
« Reply #155 on: December 2, 2008, 03:48:57 PM »
I'm no expert, but I think reflection and an eval function will get you most of the way there.


Is this what you mean?  I have a class that creates an assembly on the fly depending on some dynamic settings from a database, (here's a tiny snippet of the code with bits left out so dont follow it literally). 

Code: [Select]
private System.Reflection.Assembly CreateAssembly()
        {
            CSharpCodeProvider c = new CSharpCodeProvider();
            ICodeCompiler icc = c.CreateCompiler();
            CompilerParameters cp = new CompilerParameters();

            cp.ReferencedAssemblies.Add("system.dll");
         
            cp.CompilerOptions = "/t:library";
            cp.GenerateInMemory = true;

            CompilerResults cr = icc.CompileAssemblyFromSource(cp, sb.ToString());         

            System.Reflection.Assembly a = cr.CompiledAssembly;

            return a;
        }

An object of that class is then created, eg


Code: [Select]
mCompiledAssembly = CreateAssembly();
mObject = mCompiledAssembly.CreateInstance("myTypeName");
mObject.doInvokeSomethingCreatedOnTheFly();

Offline Deano06

  • Confirmed BOFH TECHNOBORE#1
  • Anny Roader
  • ****
  • Posts: 425
  • Smarter than you.
  • Super Title: Or is he?
Re: RAWK Web Development Circle
« Reply #156 on: December 2, 2008, 06:58:18 PM »
Not directly, of course, but plain PHP's just-plonk-me-in-the-HTML nature encourages rotten habits. A decent framework (in any language) strongly emphasises a sane application and database design.

If he'd started with Ruby on Rails, Django etc., I don't believe he'd have ever used the DB like that.

You know what you're doing, so you know to validate user input and protect against SQL injection, and how to use a DB properly, so raw PHP is fine for you. Beginners need a framework to protect them from their own mistakes.

Plain PHP gives you all this power but no indication as to how to use it properly. It doesn't force you to think about the design of the app in the slightest before starting, and you end up bashing out a site in Dreamweaver, changing all the file extensions to .php, and going through each page copying and pasting bits of PHP here and there, reading odds and sods on php.net as you go.


But any language in it's pure form will let you ' just-plonk-me-in-the-HTML'; Ruby, VBSCRIPT, Python, PHP...

You're comparing PHP (a language) against Ruby on Rails and Django (frameworks)...

A real comparison would be something like Cake, Zend, Symphony or CodeIgniter. against Ruby on Rails/ASP.net. And you'll find they all enforce application patterns (MVC). Just as Ruby on Rails and Python do but PHP applications have the advantage of being the most employable of any language.


http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html (this will give you an idea about the pains of Ruby on Rails)

I really enjoy Rails, I've written two applications in it, but for speed of development, execution, flexibility and compatibility I will always use PHP (until a better solution comes along anyway)

I see bad code in VBScript/ASP, Ruby, PHP all equally..Well I see more bad ASP classic than anything else to be honest!



Offline wacko

  • Keepsh a shecret gottle of Shcotch in hish top drawer. Cunning linguist and ical genius
  • Believer
  • ******
  • Posts: 5,205
Re: RAWK Web Development Circle
« Reply #157 on: December 2, 2008, 11:07:02 PM »

Is this what you mean?  I have a class that creates an assembly on the fly depending on some dynamic settings from a database, (here's a tiny snippet of the code with bits left out so dont follow it literally). 

Code: [Select]
private System.Reflection.Assembly CreateAssembly()
        {
            CSharpCodeProvider c = new CSharpCodeProvider();
            ICodeCompiler icc = c.CreateCompiler();
            CompilerParameters cp = new CompilerParameters();

            cp.ReferencedAssemblies.Add("system.dll");
         
            cp.CompilerOptions = "/t:library";
            cp.GenerateInMemory = true;

            CompilerResults cr = icc.CompileAssemblyFromSource(cp, sb.ToString());         

            System.Reflection.Assembly a = cr.CompiledAssembly;

            return a;
        }

An object of that class is then created, eg


Code: [Select]
mCompiledAssembly = CreateAssembly();
mObject = mCompiledAssembly.CreateInstance("myTypeName");
mObject.doInvokeSomethingCreatedOnTheFly();
If we're still talking about meta-programming, and I understand your code correctly, it would kind of depend on where sb comes from. If the source is generated on the fly, it's deffo meta-programming. If sb is static, that looks like more of a factory function.

But any language in it's pure form will let you ' just-plonk-me-in-the-HTML'; Ruby, VBSCRIPT, Python, PHP...

You're comparing PHP (a language) against Ruby on Rails and Django (frameworks)...

A real comparison would be something like Cake, Zend, Symphony or CodeIgniter. against Ruby on Rails/ASP.net. And you'll find they all enforce application patterns (MVC). Just as Ruby on Rails and Python do but PHP applications have the advantage of being the most employable of any language.


http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html (this will give you an idea about the pains of Ruby on Rails)

I really enjoy Rails, I've written two applications in it, but for speed of development, execution, flexibility and compatibility I will always use PHP (until a better solution comes along anyway)

I see bad code in VBScript/ASP, Ruby, PHP all equally..Well I see more bad ASP classic than anything else to be honest!
Deano, I clearly said I was talking about frameworks vs languages, and no, Ruby and Python will NOT let you just plonk them in HTML in their pure form.

And PHP IS a pretty shitty language. There's no consistency to function naming or, particularly, parameter ordering, not to mention the absolutely retarded type system. Whether or not namespaces and modules are possible, they're rarely used, which makes hacking existing PHP code a fucking nightmare.

You're entitled to disagree, but in all honesty I don't take your opinions of Ruby and particularly Python in the slightest bit seriously because you obviously have zero to minimal experience with them.

I can't comment on ASP because I know very little about it. Not commenting on stuff you don't know about is something you need to work on :)
Quidquid latine dictum sit, altum sonatur.

Offline Deano06

  • Confirmed BOFH TECHNOBORE#1
  • Anny Roader
  • ****
  • Posts: 425
  • Smarter than you.
  • Super Title: Or is he?
Re: RAWK Web Development Circle
« Reply #158 on: December 3, 2008, 10:51:52 AM »
I wrote this in rails:

http://ever-creative.co.uk/
http://www.bishbo.com/

I wrote these in PHP:

http://www.marchoganlive.com
http://www.brewers.co.uk
http://www.peppagame.com
http://www.burnzombieburn.com

I worked on these ASP projects

http://www.footballdirector.com
http://www.dickies.co.uk
http://www.oneilleurope.com/evolution/

So I think I am qualified to speak on the matter...

Ruby where one just freely connects to a database and works on presentation in the same file:

Code: [Select]
dbh = Mysql.real_connect("localhost", "root", "root", "somedatabase")
puts "<b>HI EVERYONE</b>"

Just as you can in PHP.

Like I said PHP is far more deployable and scalable than Ruby and Python.

I will concede that the function naming conventions are completely messed up in PHP and far better in Ruby and Python. But clients don't care about that. That want a site that is going to be developed quickly, won't have to be refactored like a RoR project inevitably will a hundred times and they want portability. Which you don't get with Ruby on Rails and Python. PHP is on 99.9% of web servers. Ruby is supported on less than 1%. Rails even less.

If you feel you are more qualified to speak on the subject. Feel free to show me your experience.

Offline Slick_Beef

  • RAWK's Master Baker
  • RAWK Supporter
  • Believer
  • ******
  • Posts: 8,806
Re: RAWK Web Development Circle
« Reply #159 on: December 16, 2008, 04:24:21 PM »
Bit of advice lads if anyone has a minute.

I've been offered a bit of freelance work. A local businessman wants to make a job-searching website, because there arent many in Portugal and the ones that exist are crap, so he thinks there's good potential in it, and I'm inclined to agree. I have all the knowledge to do it, as have done similar but smaller-scale things before with companies and through university.

I'm meeting the guy later this month to talk contract etc., but I've never actually done this as freelance work before, and I don't really know what I should be asking for... i'll be doing it just in my spare time at home, on top of my current job. Should I expect a monthly salary, or a series of bigger payments as the project progresses/finishes? I guess this is all down to what we work out but if anyone has been in this situation before I'd love to have some ideas..