<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hlegius &#187; Desenvolvimento</title>
	<atom:link href="http://www.hlegius.pro.br/category/desenvolvimento/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hlegius.pro.br</link>
	<description>programação, desenvolvimento, tecnologia e muito o que contar.</description>
	<lastBuildDate>Tue, 22 Jun 2010 15:19:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Programador apaixonado</title>
		<link>http://www.hlegius.pro.br/programador-apaixonado/</link>
		<comments>http://www.hlegius.pro.br/programador-apaixonado/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 22:10:24 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Carreira]]></category>
		<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Dia-a-dia]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/?p=599</guid>
		<description><![CDATA[Ser programador é uma coisa engraçada ! Tenho visto recentemente várias movimentações por parte de programadores, buscando juntar-se para: programar !
É possível reparar que a quantidade de grupinhos que buscam aprender coisas novas &#8211; sejam elas linguagens da hype &#8211; metodologias ou ainda algum projeto pessoal integrando algumas linguagens, dados públicos e uma interface dita [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Ser Programador" href="http://hlegius.pro.br/ser-programador" target="_blank">Ser programador</a> é uma coisa engraçada ! Tenho visto recentemente várias movimentações por parte de programadores, buscando juntar-se para: <strong>programar</strong> !<br />
É possível reparar que a quantidade de grupinhos que buscam aprender coisas novas &#8211; sejam elas linguagens da <em>hype</em> &#8211; metodologias ou ainda algum projeto pessoal integrando algumas linguagens, dados públicos e uma interface dita Web 2.0.</p>
<div class="wp-caption aligncenter" style="width: 510px"><a href="http://www.flickr.com/photos/danicuki/4671867058/in/set-72157624208353028/"><img title="Random Hack of Kindness São Paulo 2010 por danicuki" src="http://farm2.static.flickr.com/1275/4671867058_104bf2b4eb.jpg" alt="" width="500" height="333" /></a><p class="wp-caption-text">Random Hack of Kindness São Paulo 2010 por danicuki</p></div>
<p>Eventos como Yahoo! Open Hack day; Google Developer Day; o recente Random Hack of Kindness; <a href="http://www.codingdojo.org" target="_blank">Coding Dojo</a> (o de Sampa no IME da USP está meio inativo ao que consta); e vários outros movimentos iniciados até por empresas, como a própria <a href="http://www.caelum.com.br" target="_blank">Caelum</a> que já abriu as portas para criar um ambiente onde programdores pudessem se juntar e desenvolver suas coisas, ou mesmo que fechado ao grupo de programadores da mesma como já ouvi relatos de programadores.</p>
<p>O que leva esse bando de programador <em>malhucos</em> das cavernas a participarem com empolgação destes eventos &#8211; muitas das vezes apenas com <em>free lunch</em> e Internet 0800 ? São desocupados ? Loucos ?</p>
<div class="wp-caption aligncenter" style="width: 510px"><a href="http://www.flickr.com/photos/acarlos1000/4448541107/"><img title="Yahoo! Open Hack Day Brazil 2010" src="http://farm5.static.flickr.com/4020/4448541107_bf35ab2bea.jpg" alt="Yahoo! Open Hack Day Brazil 2010" width="500" height="281" /></a><p class="wp-caption-text">Yahoo! Open Hack Day Brazil 2010 por Antônio Carlos</p></div>
<p>Simples: adoram o que fazem ! São essas pessoas que geralmente criam tendências, aplicam ideias e tomam iniciativas nas corporações em que trabalham; São os mesmos developers que passam horas a fio programando com vários livros de nomes <em>nonsense</em> à tira-colo; ou que criam projetos pessoais para suprir uma necessidade própria e acabam chamando a atenção de muita gente &#8211; vide tantas <em>startups</em> bem sucessidas criadas e mantidas por programadores.</p>
<p>Geralmente esses mesmos programadores conhecem pelo menos duas linguagens. O motivo ? Curiosidade ! Pouco importa se Ruby on Rails fará sucesso no mercado coorporativo ou se Python não agrada o chefe. É legal para eles, então, investem tempo nisto.</p>
<p>Sempre em busca de novos conhecimentos, fanáticos pela arte em programar e fazer coisas novas; de novas formas e com novas ferramentas. Criam coisas, compartilham o feito e ainda passam a diante o novo conhecimento com artigos, blogs ou seminários. São programadores sempre motivados que buscam fazer uma análise crítica sobre suas próprias formas de programação buscando a evolução das ideias.</p>
<p>Vida social ? Muito bem, obrigado ! Nestas idas e vindas acabam conhecendo pessoas, lugares e oportunidades diferentes. Trocam ideias, conversam, trocam contactos das redes sociais; <acronym title="PHPinga, oi ?">juntam-se em botecos</acronym> ou equivalentes tornando o simples ato de programar em grupo em praticamente uma festa completa ! <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/programador-apaixonado/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ser programador</title>
		<link>http://www.hlegius.pro.br/ser-programador/</link>
		<comments>http://www.hlegius.pro.br/ser-programador/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 18:19:15 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[projetos]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/?p=564</guid>
		<description><![CDATA[Quando decidi, aliás, percebi, que eu tinha vontade de estudar programação, nunca passou pela minha cabeça o quão difícil era criar uma aplicação a nível profissional.
Iniciei na segunda metade de 2004, instalando um daqueles all in one for Windows (PHP, Apache, MySQL) e em uma semana estava fazendo uns ifs e submetendo formulários via HTTP [...]]]></description>
			<content:encoded><![CDATA[<p>Quando decidi, aliás, percebi, que eu tinha vontade de estudar programação, nunca passou pela minha cabeça o quão difícil era criar uma aplicação a nível profissional.<br />
Iniciei na segunda metade de 2004, instalando um daqueles <em>all in one</em> <em>for Windows</em> (PHP, Apache, MySQL) e em uma semana estava fazendo uns <em>ifs</em> e submetendo formulários via HTTP POST.</p>
<div class="wp-caption aligncenter" style="width: 510px"><a href="http://www.flickr.com/photos/harmony19490/363024712/"><img src="http://farm1.static.flickr.com/138/363024712_5783b2bee0.jpg" alt="" width="500" height="333" /></a><p class="wp-caption-text">&quot;Java printout por Ngọc Hà @ flickr&quot;</p></div>
<p>Naquela época era claro para mim que programação era algo relacionado à área de exatas, pois criar uma aplicação é algo lógico tendo envolvimento direto com matemática e tudo mais.<br />
Em coisa de um mês e pouco já conseguia fazer até uns &#8220;SQLs&#8221; e montava sites no estilo <em>macarrônico</em> de desenvolver. Aquilo para mim era fantástico! Tinha como objetivo aprender bem a linguagem para assim conseguir <a title="Zend Certified Engineer" href="http://www.zend.com/en/store/education/certification/authenticate.php/ClientCandidateID/ZEND010366/RegistrationID/231431226" target="_blank">minha certificação da Zend</a>, tornando-me assim um programador profissional.</p>
<p>Aconteceu porém, algo inesperado: comecei a &#8220;seguir&#8221; &#8211; não era no Twitter, até porque ele ainda era um protótipo de projeto na época &#8211; pessoas realmente profissionais em desenvolvimento de software e eu percebi assim que o buraco era mais embaixo e que eu ser excelente em uma linguagem era apenas um dos passos para tornar-me um programador profissional.</p>
<p>Abrindo um parênteses, eu li através do <a href="http://www.twitter.com/sergioprado" target="_blank">@sergioprado</a>, não lembro onde agora, uma frase interessante e que tem como tradução algo como:</p>
<pre>"O caminho para tornar-se mestre: siga o mestre; ande com o mestre;
torne-se o mestre."</pre>
<p>Após começar eu a seguir os mestres, pude perceber que programação vai muito além da leitura de um requisito funcional de software e fazer daquilo algo sistêmico. Hoje, arrisco-me a dizer que programação não é algo somente relacionado à exatas. Possuí também, questões éticas &#8211; humanas &#8211; e artísticas.</p>
<p><strong>A programação é relacionada a área de exatas</strong></p>
<p>Isso é bem claro aos envolvidos em desenvolvimento de software. Você lê um problema descritivo, vulgo especificação funcional, ou visual (UML, rabisco na <a href="http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&amp;field-keywords=moleskine&amp;x=0&amp;y=0" target="_blank">Moleskine</a>, <em>whatever</em>) e faz daquilo algo sistêmico e que agregue valor ao negócio de seu cliente.</p>
<p>Como premissa você precisa aprender uma linguagem. Conhecer uma linguagem bem não é nada fácil. Você precisa empenhar-se para conhecer as intrínsecas e peculiaridades para aproveitar o melhor dela, tornando-se um especialista na linguagem. Eu valorizo mais um programador excelente em uma linguagem a um que já &#8220;trabalhou&#8221; com várias. Não é impossível uma pessoa ser excelente em mais de uma linguagem, mas isto, porém, demandaria muito tempo de dedicação para atingir tal nível.</p>
<p><strong>A programação é relacionada a ética</strong></p>
<p>Toda área tem suas condutas éticas e humanas, óbvio. Em programação, porém, vejo muitos ditos programadores ignorando isto. Quando você troca qualidade por falso ganho de tempo, você está sendo antiético. Quando não analisa corretamente as decisões que irá tomar em cima de algum problema, falta-lhe ética. Quando deixa de atentar seu cliente, o que inclui seu chefe, sobre a ausência de segurança, qualidade ou algum problema em cascata que venha a aparecer em decorrência de uma atitude, você está sendo antiético.</p>
<p>E isso acontece em demasia em nossa área! Seja por falta de interesse por parte do dito programador ou mesmo por medo de perder o emprego/projeto por &#8220;afronto&#8221; ao seu chefe ou cliente.</p>
<p>Para conhecer as técnicas, metodologias e artimanhas no desenvolvimento de software é necessário antes, ter uma boa noção de análise e projeto de software; arquitetura de aplicações; padrões e melhores práticas, para, após criticar uma atitude antiética de seu chefe/cliente, você ter total embasamento para propor a solução sem comprometer o projeto nem a aplicação. Isto será necessário também, para você ter um vocabulário comum para quando estiver numa roda de conversa entre os &#8220;mestres&#8221; da área.</p>
<p>Importante ressalvar que seu cliente ou chefe pode estar tomando uma atitude antiética, no ponto de vista de programação, inconscientemente. Afinal ele é especialista no negócio, o programador profissional é você! <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>A programação é também relacionada a artes</strong></p>
<p>Há uma enorme diferença entre criar algo que funcione e criar algo que além de funcionar, transparece o domínio (regra de negócio).</p>
<p>Eu posso saber ler e escrever em português, mas há uma diferença gritante entre um poeta português e eu. Ele, diferentemente de mim, sabe utilizar muito bem as palavras e com elas, faz transparecer sentimentos, idéias e pensamentos sobre determinado tema, trazendo um enredo ao assunto abordado, envolvendo-nos em sua história.</p>
<p>Posso saber desenhar, mas isso não me torna um artista que emociona as pessoas com minhas obras.</p>
<p>Como programadores profissionais é fundamental conseguirmos fazer o mesmo ! É de nossa responsabilidade criar um código simples, legível e que conte toda a história da aplicação através de seus pacotes, classes, métodos, parâmetros, atributos e variáveis. Qualquer coisa diferente disso, não pode ser aceito como código profissional.</p>
<p>Pouco importa se a linguagem X é tachada como mais poluída que a Y. Você como profissional, tem que quebrar essa barreira e torná-la tão legível quanto qualquer outra, afinal, você é especialista na linguagem, lembra ?</p>
<p>Além de criar, é nossa responsabilidade cuidar para que o código continue sempre otimizado por tantas quantas forem as mudanças que nele ocorrer. Criar algo legível recai diretamente sobre isto, pois, no futuro outro profissional em programação poderá continuar seu trabalho sem danificar ou abandonar as premissas cruciais para um bom código. <a href="http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1272218331&amp;sr=8-1" target="_blank">Andrew Hunt</a> aborda o título: <em>&#8220;Don&#8217;t live with broken windows&#8221;</em>, onde resumidamente ele alerta para não descuidarmos da qualidade, pois, basta uma janela quebrada em uma casa para que ela transpareça o estado de abandono, fazendo assim, com que outras pessoas destruam mais janelas.</p>
<p>E como toda arte, não há uma receita para criar bons softwares. É necessário muito empenho, ler muitos códigos, revisar muitos paradigmas ao longo do tempo e claro, programar bastante. Não é possível tornar-se um programador profissional sem conhecimento teórico, tão pouco, sem vivência com erros e acertos.</p>
<p>Ao desenvolver a aplicação, não aceite nada menos do que seu melhor naquilo e atente-se para não cair na armadilha de criar softwares de forma sistematizada. Tenha autocrítica para fazer avaliações em seus próprios códigos e evitar assim, programar por coincidência.</p>
<p>Lembre-se de que será seu nome no <em><strong>@author.</strong></em> <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/ser-programador/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Review: Zend Studio 7</title>
		<link>http://www.hlegius.pro.br/zend-studio-7-review/</link>
		<comments>http://www.hlegius.pro.br/zend-studio-7-review/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 00:50:37 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/?p=372</guid>
		<description><![CDATA[Salve !
Desde quando comecei a fazer programas venho usando algumas ferramentas para desenvolver em PHP.
Na categoria Editor / IDE, na minha mão (ui) já passaram Quanta Plus, KDevelop, Eclipse PHP IDE, Netbeans for PHP e agora estou utilizando o Zend Studio. Com exceção do último, todos free ou opensource.
Netbeans é muito bom, porém o que [...]]]></description>
			<content:encoded><![CDATA[<p>Salve !</p>
<p>Desde quando comecei a fazer programas venho usando algumas ferramentas para desenvolver em PHP.<br />
Na categoria Editor / IDE, na minha mão (ui) já passaram <strong>Quanta Plus</strong>, <strong>KDevelop</strong>, <strong>Eclipse PHP IDE</strong>, <strong>Netbeans</strong><strong> for PHP</strong> e agora estou utilizando o <strong>Zend Studio</strong>. Com exceção do último, todos free ou opensource.</p>
<p>Netbeans é muito bom, porém o que me chamou a atenção no <a href="http://www.zend.com/products/studio/" target="_blank">Zend Studio</a> foi o <em>all-in-one</em> que ele traz por default. Listando rapidamente:</p>
<ul>
<li>Editor PHP</li>
<li>Integração SVN/CVS/Git</li>
<li>PHP Debugging já integrado ao Zend Debugger</li>
<li>PHP Profiling</li>
<li>Database Management e Debug</li>
<li>Um ToDo simples</li>
<li>Facilidade em achar as coisas nos projetos</li>
<li>Zend Toolbar integration para Firefox e IE &#8211; mas quem liga pro IE afinal</li>
<li>etc&#8230;</li>
</ul>
<p>Claro que não é impossível configurar toda essa penca de coisa no Eclipse nativo ou Netbeans, só que isto demandaria tempo. <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Destaque para PHP Debug, Profiling e Zend Toolbar. Isto me chamou MUITA atenção quando estava olhando reviews e também nos trinta dias de testes.</p>
<p>Além do<em> feijão com arroz </em>temos:</p>
<p><strong>1. Call Hierarchy / Type Hierarchy / Open Type Hierarchy</strong></p>
<p>Ajuda um bocado na localização nas relações entre classes e métodos dentro do projeto. No exemplo tenho um método que chama outro e esse outro chama outro. No caso, tudo dentro de mesma classe, mas funciona perfeitamente em qualquer parte do sistema &#8211; incluindo libs no <em>Include Path:</em></p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/callHierarchy.PNG"><img class="aligncenter size-full wp-image-397" title="Call Hierarchy" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/callHierarchy.PNG" alt="Call Hierarchy" width="339" height="144" /></a></p>
<p>Já o Type Hierarchy mostra a relação entre uma classe e suas relações com classes pai ou interfaces:</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/typeHierarchy.PNG"><img class="aligncenter size-full wp-image-398" title="Type Hierarchy" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/typeHierarchy.PNG" alt="Type Hierarchy" width="342" height="373" /></a></p>
<p>E o Open Type Hierarchy (Ctrl + Shift + H) auxilia a localização de objetos, arquivos e métodos dentro do projeto.</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/openTypeHierarchy.PNG"><img class="aligncenter size-medium wp-image-399" title="Open Type Hierarchy" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/openTypeHierarchy-300x260.PNG" alt="Open Type Hierarchy" width="300" height="260" /></a></p>
<p>Ainda na área de localização de elementos, há uma pesquisa mais completa (Ctrl + H) que permite localização de métodos, arquivos, classes separando por tipo e muito mais:</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/search1.PNG"><img class="aligncenter size-medium wp-image-400" title="Search (Ctrl + H)" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/search1-300x224.PNG" alt="Search (Ctrl + H)" width="300" height="224" /></a></p>
<p>Após encontrar um resultado, a tab search é exibida/focada:</p>
<p><img class="aligncenter size-full wp-image-401" title="Search Results" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/search2.PNG" alt="Search Results" width="323" height="262" /></p>
<h3></h3>
<p><strong>2. Indentação e Marcação (diff) no código:</strong></p>
<p>Outra coisa interessante &#8211; e que existe em qualquer IDE decente &#8211; é a possibilidade de trazer o que é chamado de Quick Diff. Este recurso permite mostrar de forma simples o que você alterou, removeu ou adicionou no código. Funciona com SVN, CVS e cópia do disco local. Selecione o tipo e as cores e voilà !</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/quickDiff.PNG"><img class="aligncenter size-medium wp-image-403" title="Quick diff" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/quickDiff-292x300.PNG" alt="Quick diff" width="292" height="300" /></a></p>
<p>Embora muito comum, a indentação de código é algo interessante de manter ajustado (tab com 4 espaços) e suas preferências quanto a espaço entre os elementos; posição de chave de abertura e etc;</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/indent.PNG"><img class="aligncenter size-medium wp-image-402" title="Indent" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/indent-300x257.PNG" alt="Indent" width="300" height="257" /></a></p>
<p>Nessa tela é possivel você definir praticamente tudo sobre indentação de código ! Depois de configurar ao seu gosto (ou padrão) pode exportar para XML e usar em qualquer outra ferramenta que leia o formato &#8211; qualquer Eclipse, por exemplo =P</p>
<p><strong>Depois de configurado</strong>, você pode selecionar o trecho a ter a indentação ajustada selecionando o trecho e  Ctrl + i &#8211; obrigado, Otávio pela dica; Pode formatar todo um arquivo usando Ctrl + shift + F &#8211; valeu Toscano pela tip &#8211; ou ainda, formatar TODO o projeto: <em>Selecione o Projeto no PHP Explorer, Source -&gt; Format &#8211; </em>obrigado hlegius <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Note que todos atalhos funcionam no Eclipse também <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>3. PHP Debug</strong></p>
<p>Não é um recurso muito usado pelos developers PHP, principalmente aqueles que começaram com PHP, como eu, mas sem dúvidas revoluciona a forma de como você desenvolve. Após adotar o debug você não quer mais saber de var_dump() ou print_r() com aqueles: &#8216;estou aqui&#8217; para verificar o que pegou na aplicação.</p>
<p>Como o PHP é baseado em Web, seria fundamental ele poder ser debugado como se estivesse sendo carregamento pelo browser, não ? E é exatamente isso que permite o Zend Debugger &#8211; o Xdebug também =~</p>
<p>Ambas engines de debug podem ser integradas ao Zend Studio, porém, no pacote do Studio já vem a versão mais recente do Zend Debugger e tudo já meio que ajustado para rodar com ele <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>É possível debugar um script PHP Modo terminal e claro, o PHP Web Debug. Para este último você fornece a URL que quer debugar e ele abre a sessão de debugging parando na primeira linha.</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug1.PNG"><img class="aligncenter size-medium wp-image-404" title="Zend Debugger + Studio" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug1-300x267.PNG" alt="Zend Debugger + Studio" width="300" height="267" /></a></p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug2.PNG"><img class="aligncenter size-medium wp-image-405" title="Zend Debugger + Studio" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug2-300x225.PNG" alt="Zend Debugger + Studio" width="300" height="225" /></a></p>
<p>Utilizando os breakpoints você pode acompanhar o fluxo da aplicação, valores das variáveis, propriedades dos objetos instanciados e etc.</p>
<p>Claro que nossas aplicações vão muito além de uma simples URL. Temos chamadas com POST, GET e até chamadas em <em>Ajax</em>. O Zend Studio provê uma extension para o Firefox chamada <strong>Zend Toolbar</strong>. Essa toolbar, permite que você diga ao browser para chamar a sessão de Debug ou Profiling do Studio na próxima página; página atual; Qualquer submit POST ou ainda em qualquer ação no browser. E o pior: funciona !</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug3.PNG"><img class="aligncenter size-medium wp-image-406" title="Zend Studio + Zend Toolbar" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug3-300x242.PNG" alt="Zend Studio + Zend Toolbar" width="300" height="242" /></a></p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug4.PNG"><img class="aligncenter size-medium wp-image-407" title="Zend Studio - Debug Perpective" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/debug4-300x119.PNG" alt="Zend Studio - Debug Perpective" width="300" height="119" /></a></p>
<p>A configuração do Zend Debugger na sua máquina é simples, mas acho ser digna de um post inteiro sobre isto. Vou tentar preparar um material e publico aqui a configuração e uso dele no Zend Studio.</p>
<p><strong>4. PHP Profile</strong></p>
<p>Além de debuggar, seria interessante analisarmos o desempenho da aplicação. Ok, segue:</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/profile.PNG"><img class="aligncenter size-medium wp-image-408" title="PHP Profile Zend Studio" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/profile-300x201.PNG" alt="PHP Profile Zend Studio" width="300" height="201" /></a></p>
<p>Chamadas, quantas vezes chamou; quem demora mais; quem é mais rápido; quem chama quem;</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/profile2.PNG"><img class="aligncenter size-medium wp-image-409" title="PHP profile - Zend Studio" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/profile2-300x254.PNG" alt="PHP profile - Zend Studio" width="300" height="254" /></a></p>
<p>E ele, o fluxo da aplicação:</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/profile3.PNG"><img class="aligncenter size-medium wp-image-410" title="PHP Profile - Zend Studio" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/profile3-300x256.PNG" alt="PHP Profile - Zend Studio" width="300" height="256" /></a></p>
<p>A Zend Toolbar também provê acesso simples ao Profiling. Basta clicar em Profile na toolbar e pronto. O Studio é chamado e o profile da página é feito.</p>
<p><strong>5. Database Management</strong></p>
<p>Para fechar, gerenciamento dos databases. Possui ponte para vários databases incluindo Oracle, MySQL, PostgreSQL e MSSQL.</p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/database.PNG"><img class="aligncenter size-medium wp-image-411" title="Database - Zend Studio" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/database-181x300.PNG" alt="Database - Zend Studio" width="181" height="300" /></a></p>
<p>Por ele é possível adicionar valores, editar, remover, rodar <em>Queries SQL</em>, backup de estrutura e valores e ele também armazena suas Queries para re-executá-las com um clique quando quiser.</p>
<p><strong>6. Outros</strong></p>
<p><a href="http://www.hlegius.pro.br/wp-content/uploads/2010/01/svn.png"><img class="aligncenter size-medium wp-image-412" title="SVN - Zend Studio" src="http://www.hlegius.pro.br/wp-content/uploads/2010/01/svn-242x300.png" alt="SVN - Zend Studio" width="242" height="300" /></a></p>
<p>SVN, projetos remotos &#8211; incluindo acesso SMB ou FTP; WebServices; Históricos locais, SVN, diff, suporte a Git e suporte a quaisquer plugins que rodem no Eclipse, afinal o Zend Studio tem como base o Eclipse.</p>
<p>Já o configurei no Ubuntu lá na Vex, Windows 7 e Arch Linux aqui no escritório pessoal. Tudo muito tranquilo, sempre.</p>
<p><strong>7. Preços e licença</strong></p>
<p>O custo da licença eu acho alto demais para uma IDE de desenvolvimento. Atualmente são US$ 400,00 por ano para ter suporte e atualização sempre. Caso queira, pode comprar a licença por um ano e depois não comprar mais. Neste caso você ficaria com a última versão antes da expiração de seu suporte ilimitado. Em miúdos: enquanto você paga, recebe atualização da versão.</p>
<p>Comprei em setembro, na versão 7. Em Setembro de 2010, vamos imaginar que esteja na versão 9. Terei as licenças para 7, 8 e 9. Expirou e não renovei, mas saiu update da versão 9, a 9.1, por exemplo. Tenho update dela, pois a licença é a mesma da 9. Porém, no lançamento da 10, eu precisaria comprar uma nova licença para ter direito de baixar e usar a o v10.</p>
<p><strong>Minha opinião final:</strong> gostei e tenho usado apenas ele desde quando comecei a testá-lo em meados de Setembro de 2009. Tem muita coisa boa e que ajuda muito e mesmo com o alto custo, vale cada centavo pago até o presente momento.</p>
<p><em>#notamental não é post patrocinado, tão pouco trabalho na Zend, certo ? <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/zend-studio-7-review/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Exceptions. Pois nem tudo é perfeito</title>
		<link>http://www.hlegius.pro.br/exceptions-pois-nem-tudo-e-perfeito/</link>
		<comments>http://www.hlegius.pro.br/exceptions-pois-nem-tudo-e-perfeito/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 14:44:10 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Segurança]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/?p=313</guid>
		<description><![CDATA[Salve !
Pense numa rotina que desenvolveu. Qualquer uma ! Agora tente se recordar de quantas formas ela poderia ser quebrada pelo usuário, gerando assim algo inexperado na sua aplicação fazendo com que você retornasse um erro para o cliente.
E qual é a forma que você utiliza para retornar estes erros ? Veja, eu posso ajudar [...]]]></description>
			<content:encoded><![CDATA[<p>Salve !</p>
<p>Pense numa rotina que desenvolveu. Qualquer uma ! Agora tente se recordar de quantas formas ela poderia ser quebrada pelo usuário, gerando assim algo inexperado na sua aplicação fazendo com que você retornasse um erro para o cliente.</p>
<p>E qual é a forma que você utiliza para retornar estes erros ? Veja, eu posso ajudar a recordar você:</p>
<div class="igBar"><span id="lcode-5"><a href="#" onclick="javascript:showPlainTxt('code-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-5">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?php</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">function foobar<span style="color:#006600; font-weight:bold;">&#40;</span>$nome<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;if <span style="color:#006600; font-weight:bold;">&#40;</span>strlen<span style="color:#006600; font-weight:bold;">&#40;</span>$nome<span style="color:#006600; font-weight:bold;">&#41;</span> &lt;<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return -<span style="color:#800000;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;if <span style="color:#006600; font-weight:bold;">&#40;</span>strpos<span style="color:#006600; font-weight:bold;">&#40;</span>$nome,<span style="color:#CC0000;">"foo"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return -<span style="color:#800000;color:#800000;">2</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;echo $nome;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;return <span style="color:#800000;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Com isso lá na sua Action você fica fazendo malabarismo para encontrar o erro retornado e gerar a mensagem para o usuário. Não demorará muito para você criar sua tabela de erro:</p>
<ul>
<li>-1 para erros de entrada</li>
<li>-2 para erros de máscara</li>
<li>-3 para calcúlos errados</li>
<li>-4 para usuário não logado</li>
<li>-5 ....</li>
<li>-7634 ....</li>
</ul>
<p>Realmente, bem simples assim né ? Só consultar a tabela e mandar bala.</p>
<p>Eu realmente não entendo o motivo de muitos não utilizarem a<a href="http://br.php.net/exception" target="_blank"> classe nativa de exceções do PHP</a>. É simples, é funcional e<em> de grátis</em> você não precisa montar sua tabelinha de códigos de erro.</p>
<p>Veja o mesmo código reescrito utilizando a tal classe:</p>
<div class="igBar"><span id="lcode-6"><a href="#" onclick="javascript:showPlainTxt('code-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-6">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?php</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">function foobar<span style="color:#006600; font-weight:bold;">&#40;</span>$nome<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;if <span style="color:#006600; font-weight:bold;">&#40;</span>strlen<span style="color:#006600; font-weight:bold;">&#40;</span>$nome<span style="color:#006600; font-weight:bold;">&#41;</span> &lt;<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;throw new Exception <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"O nome não é válido !"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;if <span style="color:#006600; font-weight:bold;">&#40;</span>strpos<span style="color:#006600; font-weight:bold;">&#40;</span>$nome,<span style="color:#CC0000;">"foo"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; throw new Exception<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"O nome precisa conter foo, cara !"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;echo $nome;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Com isso na sua Action, simplesmente:</p>
<div class="igBar"><span id="lcode-7"><a href="#" onclick="javascript:showPlainTxt('code-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-7">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?php</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">include <span style="color:#CC0000;">"function_foobar.php"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">try <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; foobar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"ab"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> catch <span style="color:#006600; font-weight:bold;">&#40;</span>Exception $e<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; $var_template_sem_merchan_pro_smarty-&gt;<span style="">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'retorno_de_erro'</span>,$e-&gt;<span style="">getMessage</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Assim, você pode ter 1, 2, 3, <em>n</em> mensagens de erro em <em>n</em> camadas da aplicação sem a necessidade de se preocupar em tratar uma a uma também na Action. Fica ultra-transparente na Action além de economizar seus dedos refazendo coisas que já estavam prontas camadas a dentro.</p>
<p><strong>Nota</strong>: Não esqueça disso <strong>nunca</strong> : <span style="color: #ff0000;">jamais</span> lance como exception uma mensagem de erro do PHP. Isso é feio - porque vem em inglês -, você será xingado por 3 gerações futuras de programadores além de permitir que os usuários vejam detalhes sobre sua aplicação.</p>
<h5>Como detectar os erros sem lança-los ao usuário ?</h5>
<p>Bem simples. Persista-os - eita mania - em arquivos de log. Mas calma, antes de sair criando algo com fopen(), leia isto: o PHP também traz o cara que salva - persiste - erros ! Ah sim, o PHP é excelente eu sei. Voltando ao exemplo...</p>
<p>
<div class="igBar"><span id="lcode-8"><a href="#" onclick="javascript:showPlainTxt('code-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-8">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?php</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">function foobar<span style="color:#006600; font-weight:bold;">&#40;</span>$nome<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;if <span style="color:#006600; font-weight:bold;">&#40;</span>strlen<span style="color:#006600; font-weight:bold;">&#40;</span>$nome<span style="color:#006600; font-weight:bold;">&#41;</span> &lt;<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error_log<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"O cara forneceu "</span>. $nome . <span style="color:#CC0000;">" e isto é inválido <span style="color:#000099; font-weight:bold;">\n</span>"</span>, <span style="color:#800000;color:#800000;">3</span>, <span style="color:#CC0000;">"seu_arquivo_de_log.txt"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;throw new Exception <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"O nome não é válido !"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;if <span style="color:#006600; font-weight:bold;">&#40;</span>strpos<span style="color:#006600; font-weight:bold;">&#40;</span>$nome,<span style="color:#CC0000;">"foo"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; error_log<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"O cara forneceu "</span>. $nome . <span style="color:#CC0000;">" porém sem o foo !<span style="color:#000099; font-weight:bold;">\n</span>"</span>, <span style="color:#800000;color:#800000;">3</span>, <span style="color:#CC0000;">"seu_arquivo_de_log.txt"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// #notamental não há motivos para logar &quot;erros&quot; deste tipo. Estou apenas ilustrando seu funcionamento <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;throw new Exception<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"O nome precisa conter foo, cara !"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; echo $nome;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Sim, ele, o <a href="http://br.php.net/error_log" target="_blank">error_log()</a> salva o log para ti. E pior, digo, melhor: caso queira ele pode enviar a notificação no seu e-mail. Certo, em boa parte dos casos isto definitivamente não é uma boa ideia. Mas pode ser útil algum dia, penso.</p>
<p>Resumo do dia: use ao máximo as <a href="http://br.php.net/exception" target="_blank">Exceptions</a> e as <a href="http://br.php.net/manual/pt_BR/ref.errorfunc.php" target="_blank">funções para tratamento de erros do php</a> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/exceptions-pois-nem-tudo-e-perfeito/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Indentação de códigos</title>
		<link>http://www.hlegius.pro.br/indentacao-de-codigos/</link>
		<comments>http://www.hlegius.pro.br/indentacao-de-codigos/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 15:43:04 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Organização]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/identacao-de-codigos/</guid>
		<description><![CDATA[É fato que cada programador tem suas técnicas e formas de trabalhar: preferências por Frameworks - ou preferência por trabalhar sem uma - preferências na plataforma (Linux, OSX, Windows, Solaris, *BSD...), preferências por IDEs de desenvolvimento (Eclipse, Zend Studio, Aptana, NetBeans, Kdevelop, Anjuta...) e isso não seria diferente quando o assunto é indentação de códigos.
Pensando [...]]]></description>
			<content:encoded><![CDATA[<p>É fato que cada programador tem suas técnicas e formas de trabalhar: preferências por Frameworks - ou preferência por trabalhar sem uma - preferências na plataforma (Linux, OSX, Windows, Solaris, *BSD...), preferências por IDEs de desenvolvimento (Eclipse, Zend Studio, Aptana, NetBeans, Kdevelop, Anjuta...) e isso não seria diferente quando o assunto é <strong>indentação de códigos</strong>.</p>
<p>Pensando rapidamente parece um absurdo tratar sobre isto, mas acredite, assim como temos os Freetards - pessoas que têm amor ao Software Livre e critica todo o resto - Mactards, Wintards temos os programadores que <strong>descutem</strong> sobre indentação do código ! E acredite, tem "grupos" de programadores, cada qual defendendo um lado ! Loucura ? Continue lendo !</p>
<p><strong>Nosso ponto de partida..</strong><br />
Como eu não sei exatamente onde que teve inicio isto, tomaremos como ponto de partida a publicação do livro <em>The C Programming Language</em>, escrito por Brian Kernighan e Dennis Ritchie. No livro você percebe que eles indentam o código da seguinte forma:</p>
<p><img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_krstyle.png' alt='Kernighan and Ritchie Style Identing' /></p>
<p>Porém, há uma exclusão aí ! Quando temos funções, a indentação desta é diferenciada, veja:</p>
<p><img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_krstyle_function.png' alt='Kernighan and Ritchie - Function Style Identing' /></p>
<p>Repare que nestes casos, a abertura de chaves fica abaixo da linha que indentifica a função. Em todo o resto, a chave de abertura ficará na mesma linha.</p>
<p><strong>Nota:</strong> vale lembrar que a mesma dupla que definiu que <em>"Os nomes de variáveis e funções tem que expressar o significado do que ela armazena/executa, entretando o nome não pode ser extenso demais."</em></p>
<p><strong>Em desacordo, nascem outras formas...</strong></p>
<p><strong>1. Eric Paul Allman - "Allman Style"</strong><br />
Vejamos a forma que ele usa e defende(defendia) :</p>
<p><img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_allman.png' alt='Eric Allman Identing code' /></p>
<p>A explicação é clara, assim como o código: isso evita que tenhamos linhas cheia de "tabs" apenas com chaves lá no final. Uma vez que as chaves sempre ficariam antes do conteúdo do bloco de código. É, até que tem sentido...</p>
<p><strong>2. Whitesmiths Style</strong><br />
Esse estilo é usado pela <a href="http://www.symbian.com/">Symbian</a> ao desenvolver as aplicações em C++ para seus dispositivos móveis.</p>
<p><img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_whitesmiths.png' alt='Whitesmiths - Code Style' /></p>
<p>As chaves do bloco ficam abaixo da última letra do nome do método/construtor da linguagem. Ao que me parece, era usado nos primórdios do Windows também. (Carece de fontes confiáveis)</p>
<p><strong>3. GNU Emacs</strong><br />
Sim, o guru do Software Livre também entrou nessa e criou seu estilo. Ele nada mais é do que a mistura do Allman com a Whitesmiths.</p>
<p><img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_gnu.png' alt='Gnu Code Style' /></p>
<p>O código é indentado da seguinte forma: após o *if* você vai para linha debaixo e dá 2 espaços, e então coloca a abertura da chave do bloco. Vai para a linha debaixo novamente, e dê mais 2 espaços avançando dentro dos dois anteriores. Aí agora pode colocar seu código <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Analisando alguns códigos...</strong><br />
Vejamos alguns códigos por aí a fora para ver o que a galera acha "pop".</p>
<p><strong>- Código fonte Kernel do Linux (arquivo proc.c)</strong><br />
<img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_kernellinux.png' alt='Identação do Kernel do Linux' /></p>
<p><strong>- Código fonte Mozilla Firefox (GranParadiso Alpha8) (arquivo nsBrowserApp.cpp)</strong><br />
<img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_firefox.png' alt='Identação de código do Mozilla Firefox GranParadiso Alpha8' /></p>
<p><strong>- Código fonte The Vim Editor (arquivo edit.c)</strong><br />
<img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_vi72.png' alt='Identação de código do VI Editor 7.2' /></p>
<p><strong>- Código fonte Zend Framework 1.5 (arquivo Action.php)</strong><br />
<img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_zendphp.png' alt='Identação de código do Zend PHP Framework' /></p>
<p><strong>- E claro, a "minha" forma de indentação</strong><br />
<img src='http://www.hlegius.pro.br/wp-content/uploads/2008/08/identacao_hlegius.png' alt='Identação de códigos de hlegius' /></p>
<p><strong>Resumindo....</strong><br />
Pegando emprestado o resumo do <a href="http://www.emacswiki.org/cgi-bin/wiki/IndentingC#toc4">EmacsWiki.org</a>, temos:</p>
<blockquote><p>“gnu”<br />
    The default style for GNU projects<br />
“k&#038;r”<br />
    What Kernighan and Ritchie, the authors of C used in their book<br />
“bsd”<br />
    What BSD developers use, aka “Allman style” after Eric Allman.<br />
“stroustrup”<br />
    What Stroustrup, the author of C++ used in his book<br />
“linux”<br />
    What the Linux developers use for kernel development<br />
“python”<br />
    What Python developers use for extension modules<br />
“java”<br />
    The default style for java-mode (see below)<br />
“user”<br />
    When you want to define your own style</p></blockquote>
<p>Para fechar o post, deixo aqui uma frase que encontra-se no livro <em>The Programming C Language</em>:</p>
<blockquote><p>The position of braces is less important, although people hold passionate beliefs. We have chosen one of several popular styles. Pick a style that suits you, then use it consistently.</p></blockquote>
<p><strong>Veja também:</strong> (Links em inglês)<br />
<a href="http://www.emacswiki.org/cgi-bin/wiki/IndentingC">http://www.emacswiki.org/cgi-bin/wiki/IndentingC</a><br />
<a href="http://en.wikipedia.org/wiki/Symbian_OS">http://en.wikipedia.org/wiki/Symbian_OS</a><br />
<a href="http://en.wikipedia.org/wiki/Indent_style">http://en.wikipedia.org/wiki/Indent_style</a><br />
<a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=446444">http://www.gamedev.net/community/forums/topic.asp?topic_id=446444</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/indentacao-de-codigos/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Design Patterns e o PHP</title>
		<link>http://www.hlegius.pro.br/design-patterns-e-o-php/</link>
		<comments>http://www.hlegius.pro.br/design-patterns-e-o-php/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 10:40:10 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[OOP e Patterns]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[artigos]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[Programação]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/design-patterns-e-o-php/</guid>
		<description><![CDATA[Salve!
Quem já ouviu falar de design patterns e que programa em PHP ? Melhor: quem que programa em PHP e está utilizando qualquer uma das patterns mais conhecidas ?
Isso não é nada espantoso! Os programadores PHP em sua grande parcela ainda não acordaram para a nova realidade: código mais extensível e pensado. Nunca falei aqui, [...]]]></description>
			<content:encoded><![CDATA[<p>Salve!</p>
<p>Quem já ouviu falar de design patterns e que programa em PHP ? Melhor: quem que programa em PHP e está utilizando qualquer uma das patterns mais conhecidas ?</p>
<p>Isso não é nada espantoso! Os programadores PHP em sua grande parcela ainda não acordaram para a nova realidade: código mais extensível e pensado. Nunca falei aqui, mas acho que o PHP tem um defeito grave: ser super simples. Isso estragou, em partes a fama da linguagem.</p>
<p>Vamos a um exemplo: duelo. Java Vs PHP.</p>
<p>Java: Hello world no shell</p>
<div class="igBar"><span id="ljava-14"><a href="#" onclick="javascript:showPlainTxt('java-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-14">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> HelloWorld <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Hello World!"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>PHP procedural</p>
<div class="igBar"><span id="lphp-15"><a href="#" onclick="javascript:showPlainTxt('php-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-15">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'Hello world'</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>PHP O.O</p>
<div class="igBar"><span id="lphp-16"><a href="#" onclick="javascript:showPlainTxt('php-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-16">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> HelloWorld <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;public <span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'HelloWorld'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$hw</span> = <span style="color:#000000; font-weight:bold;">new</span> HelloWorld<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>O que é mais fácil ? PHP ou Java ? PHP procedural ou PHP O.O ? Essa facilidade fez com que várias aplicações inseguras e mal pensadas infestassem a rede, causando uma rejeição do PHP por parte de vários Clientes e com isso, empresas de desenvolvimento de software. Isso é ruim para a linguagem, ruim para o profissional sério e ruim para o cliente que terá que pagar mais caro por uma tecnologia como o Java.</p>
<p>Hélio, tá, mas onde entra os design patterns nessa sua conversa mole ? Ok, até o momento eu tangenciei o tema, mas veja que para existir Pattern é ideal que haja Programação Orientada a objetos com tudo que temos direito.</p>
<p>Design patterns nada mais é que um conjunto de conceitos que visa auxiliar na resolução de um problema comum entre os programadores de verdade.</p>
<p><strong>E dale exemplos</strong></p>
<p><strong>MVC (Model View Control - Modelo Visualização Controle) ::</strong> essa Pattern foi desenvolvida para resolver o problema da lambança de códigos, ou seja, um arquivo faz tudo: conecta no banco, traz dados, exibe na tela, pega retorno do cliente, aplica regra de negócio e salva no banco.<br />
Imagine uma aplicação como E-commerce feita desta forma! Loucura hein! Falando em lambança, encontrei recentemente em um dos projetos que assumi, um arquivo <em>executa.php</em>. Já ouviu falar dele ? O "faz tudo" ? Não ? Assunto para outro post!</p>
<p>Então, como eu ia dizendo: para resolver o problema de manter tudo nas "costas" de uma mesma aplicação, foi pensado e desenvolvido esse <strong>modelo MVC</strong> onde a aplicação fica separada em camadas. Na camada mais baixa, fica o modelo, que faz a interação com o servidor de banco de dados, sistema de arquivos e etc.; Depois temos a classe que processa os dados recebidos pelo usuário e se passar por checagens simples é entregue a "Model"; e por fim, temos a View que nada mais é do que o HTML que o usuário vê, sem PHP, sem CSS sem Javascript misturado.</p>
<p>Criando um diagrama bobo temos:</p>
<blockquote><p>Banco de dados -> Model -> Controller -> View</p></blockquote>
<p><strong>View:</strong> Usuário clica no botão submit com o campo Nome preenchido.<br />
<strong>Controller </strong> recebe esse formulário. Verifica se o nome tá setado (sem checar seu valor). Setado ? Ok, manda para a model.<br />
<strong>Model</strong> recebe e aplica a regra de negócio: no exemplo, o nome precisa ter pelo menos 3 caracteres. Tem ? Ok, pega o poll de conexão com o banco de dados e salva.<br />
Retorna "true" para a <strong> Controller</strong> que exibe uma mensagem de "Sucesso" na <strong>View</strong></p>
<p><strong>DAO: (Data Access Object) </strong>:: Essa Pattern tem como objetivo separar a <em>Model</em> em dois: regra de negócio do acesso ao banco de dados. No nosso exemplo anterior, a <em>Usuario.php</em> receberia da <em>UsuarioController.php</em> o dado e a mesma aplicaria a regra de negócio. Após estar ok, a <em>Usuario.php</em> enviaria o status de "ok, pode gravar" para o UsuarioDao.php e este gravaria a informação no banco (verificando se o nome não existe por exemplo) e retornaria a informação de "true" para nosso <em>Usuario.php.</em><br />
Veja que ela tem como objetivo deixar a <em>Model</em> mais limpa e legível à manter regra de negócio e acesso ao banco tudo junto.</p>
<p><strong>Factory Pattern (Fábrica)</strong> :: tem por objetivo englobar vários recursos dentro de um mesmo método usando os blocos de condição "if" ou "switch". Exemplo:</p>
<div class="igBar"><span id="lphp-17"><a href="#" onclick="javascript:showPlainTxt('php-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-17">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Usuario <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;public <span style="color:#000000; font-weight:bold;">function</span> Pesquisa<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">switch</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$p</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#616100;">case</span> <a href="http://www.php.net/is_numeric"><span style="color:#000066;">is_numeric</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$p</span>-&gt;<span style="color:#006600;">Id</span><span style="color:#006600; font-weight:bold;">&#41;</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// Faz a pesquisa tomando como base o ID do cliente</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#616100;">case</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$p</span>-&gt;<span style="color:#006600;">Nome</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt; <span style="color:#CC66CC;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// Faz a pesquisa tomando como base o Nome do cliente</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Veja que no exemplo o método <em>Pesquisa()</em> é um só mas dependendo do tipo de informação que ele recebe, executa uma ação diferente. Isso é a <strong>Pattern Factory</strong>, novamente resolvendo outro problema usando conceitos simples. Uma outra forma de resolver o mesmo problema seria criando vários métodos<em> PesquisaId() PesquisaNome()</em>, porém, estariamos deixando de lado a Pattern Factory.</p>
<p><strong>Singleton ::</strong> essa Pattern tem como objetivo evitar que uma mesma variável, poll de conexão e etc., ocupe mais espaço na memória. Vamos a um exemplo:</p>
<p><a href='http://www.hlegius.pro.br/wp-content/uploads/2007/11/singleton.jpg' title='Singleton - Pattern'><img src='http://www.hlegius.pro.br/wp-content/uploads/2007/11/singleton.jpg' alt='Singleton - Pattern' /></a></p>
<p>No desenho que criei no Gimp, ao conectar com o banco é alocado certo endereço da memória para ele. Caso eu faça outra requisição de conexão, ao invés de alocar outro endereço de memória, ele vai usar o mesmo endereço. Pense em algo fixo. Posso fazer "n" requisições que ele sempre usará o mesmo espaço que foi alocado inicialmente.</p>
<p>A mágina está no <strong>public static $Con</strong>. Estou definindo que o <strong>$Con</strong> será estático.<br />
Abaixo, o script que está na imagem:</p>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showPlainTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> BancoDados <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <a href="http://www.php.net/static"><span style="color:#000066;">static</span></a> <span style="color:#0000FF;">$Con</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;private <span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/**</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Abre uma conexão com o MySQL</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> Conecta<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>self::<span style="color:#0000FF;">$Con</span> instanceof PDO<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#616100;">return</span> self::<span style="color:#0000FF;">$Con</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; self::<span style="color:#0000FF;">$Con</span> = <span style="color:#000000; font-weight:bold;">new</span> PDO<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"mysql:host="</span> . SERV . </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">";dbname="</span> . NAME . <span style="color:#FF0000;">""</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; USER,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PASS</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> self::<span style="color:#0000FF;">$Con</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Caso tenha interessado o assunto, você poderá pesquisar outras diversas Patterns que propõem solução para vários outros "problemas" que temos diariamente. Esse foi apenas um panorama geral sobre Design Patterns.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/design-patterns-e-o-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Frameworks PHP versus Código na unha</title>
		<link>http://www.hlegius.pro.br/frameworks-php-versus-codigo-na-unha/</link>
		<comments>http://www.hlegius.pro.br/frameworks-php-versus-codigo-na-unha/#comments</comments>
		<pubDate>Sun, 04 Nov 2007 13:11:33 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[OOP e Patterns]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programação]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/frameworks-php-versus-codigo-na-unha/</guid>
		<description><![CDATA[Salve!
Com o advento do PHP 5 OO, começaram a surgir o que já era esperado: uma chuva de frameworks. Tem framework para quase tudo hoje: XML, manupilação de dados, automatização de rotinas na view, abstração de database, até modelos mais avançados, complexos e completos como o CodeIngniter e o Symfony. Mas até onde isso é [...]]]></description>
			<content:encoded><![CDATA[<p>Salve!</p>
<p>Com o advento do PHP 5 OO, começaram a surgir o que já era esperado: uma chuva de frameworks. Tem framework para quase tudo hoje: XML, manupilação de dados, automatização de rotinas na view, abstração de database, até modelos mais avançados, complexos e completos como o <a href="http://codeigniter.com">CodeIngniter</a> e o <a href="http://www.symfony-project.com/">Symfony</a>. Mas até onde isso é vantajoso ? Será que nós programadores estamos preparados para nos adaptarmos a essas frameworks ?</p>
<p><strong>1. Conhecendo os participantes<br />
</strong>Quando produzimos um software temos em mente que aquela aplicação é totalmente conhecida por nós, ou pelo menos o máximo possível, e que atrás dela há apenas Classes e funções criadas por nós e linguagem nativa (no caso o PHP).</p>
<p>Com frameworks temos um cenário totalmente diferente: código código e mais código por trás daquela framework que nós não temos a minima noção do que faz, onde há possíveis falhas e se aquela era a melhor forma de se fazer tal funcionabilidade. Entretanto, temos um "modelo" bem genérico ao nosso dispor, evitando que percamos tempo criando algo que tem pronto.</p>
<p>Os defensores de frameworks dizem que se você não sabe o que tem dentro da framework é porque você não quer saber o que há nela e ponto. Por outro lado, os defensores do código "na unha", dizem que se é para usar frameworks, ler a mesma seria uma tremenda perca de tempo e sendo assim, é melhor criar suas próprias classes/funções e usar em suas aplicações todas.</p>
<p><strong>2. Quebrando paradigmas</strong><br />
Com o tempo estive analisando os prós e contras da framework e hoje, consegui chegar a uma linha de pensamento que talvez seja agradável ou não para você: "Frameworks. Consuma com moderação.".<br />
E é exatamente isso que tenho feito de uns tempos para cá: uso algumas poucas frameworks para auxiliar em algumas tarefas e o resto eu vou criando na mão e criando meu "pacote".</p>
<p>Não adianta ser radical. Não usar framework nenhuma é meio que loucura atualmente. Se você é das antigas e já tem seus pacotes até pode ser, mas começar hoje a nadar contra a maré é suicídio.</p>
<p>Eu faço assim atualmente:<br />
<em><strong>Pergunto :</strong> A framework "X" faz o que ?<br />
<strong>Respondo:</strong> ah, de acordo com o site, ele cria um blog em 20 minutos.<br />
<strong>Afirmo: </strong>Então essa framework é a "tal" que faz tudo ? Ótimo, não serve para mim!</em></p>
<p>Você pode estar me xingando a rodo neste momento, mas tenho para mim que ficar preso a uma framework é suicídio! Ficarei dependente de algo assim como um drogado depende da droga! Loucura! Se encontrar um problema na framework, terei que esperar uma nova versão, ou então debugar tudo para encontrar  o erro/solução; Pensa no <a href="http://wordpress.com">WordPress</a>: tem uma falha, todo mundo que tem o <a href="http://wordpress.com">WordPress</a> instalado fica preocupado, pois é por lá que entrarão no seu sistema e danificarão suas informações. afinal o bug é público! E adaptar-se a nova forma de trabalho daquela framework, também não é tarefa fácil.</p>
<p>Estive vendo o <a href="http://www.symfony-project.com/">Symfony PHP</a> e constatei que ele é estilo o <a href="http://www.rubyonrails.org/">Ruby On Rails</a>! Tudo por linha de comando. Tenho que ficar digitando comandos no meu querido <a href="http://www.flickr.com/photos/hlegius/1330961101/">shell</a> para criar coisas dentro do projeto ? Não, isso infelizmente não é minha realidade!</p>
<p>Para mim, framework está como uma "biblioteca" de recursos, e não um novo modo de trabalhar com a linguagem de programação.</p>
<p><strong>3. Frameworks</strong><br />
Atualmente eu estou utilizando a framework <a href="http://jquery.com">Jquery</a> para Javascript e o <a href="http://smarty.php.net">Smarty Template</a> para templates no PHP.</p>
<p>Talvez um dia eu mude de concepção, mas atualmente estou bem feliz assim e creio que muitos estejam como eu <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/frameworks-php-versus-codigo-na-unha/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Ferramentas livres que auxiliam o desenvolvimento web. Parte 2</title>
		<link>http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-2/</link>
		<comments>http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-2/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 22:27:00 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Dia-a-dia]]></category>
		<category><![CDATA[Software livre]]></category>
		<category><![CDATA[Programação]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-2/</guid>
		<description><![CDATA[Salve!
Este post  o segundo post da srie Ferramentas livres que auxiliam o desenvolvimento web.
De acordo com nosso cronograma, nesse segundo post, iremos falar de aplicaes que auxiliam o desenvolvimento de banco de dados.
No deixe de ler tambm, o primeiro post da srie!
Prompt interativo do servidor de banco de dados Esse todos ns conhecemos! S [...]]]></description>
			<content:encoded><![CDATA[<p>Salve!</p>
<p>Este post  o segundo post da srie <em>Ferramentas livres que auxiliam o desenvolvimento web</em>.<br />
De acordo com nosso cronograma, nesse segundo post, iremos falar de <em>aplicaes que auxiliam o desenvolvimento de banco de dados</em>.</p>
<p>No deixe de ler tambm, o <a href="http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-1/">primeiro post</a> da srie!</p>
<p><strong>Prompt interativo do servidor de banco de dados</strong> Esse todos ns conhecemos! S entrar no prompt (Windows) ou terminal(Unix Like) e cham-lo. Por exemplo:</p>
<p><strong><em># mysql -u usuario_banco -p</em></strong></p>
<p><img src="http://helio.hlegius.pro.br/imagens/screen/db_prompt_mysql.png" alt="[img] Prompt interativo MySQL Client" /></p>
<p>Pode parecer bobagem, mas com ele eu consigo gerenciar at os bancos de dados que esto aqui, neste servidor. Basta ter habilitado tal recurso no servidor de hospedagem e voc poder gerenciar os dbs remotamente sem crise.</p>
<p><strong>PHPMyAdmin</strong><br />
Com ele,  possvel gerenciar seus banco de dados com uma interface web-based simples. Alguns no gostam do estilo ou da forma de trabalho dele, mas enfim ele  muito prtico e cumpre bem seu papel.</p>
<p><strong>Aqua Studio - <a href="http://www.aquafold.com/">http://www.aquafold.com</a></strong><br />
Essa dica eu peguei com um camarada meu, o <a href="http://www.hokahey.org">hokahey</a>.<br />
O <a href="http://www.aquafold.com/">Aqua Studio</a>  uma aplicao em Java bem completa para gerenciar vrios tipos de SGBD's. MySQL, Firebird, Oracle, PostgreSQL, Interbase dentre vrios outros.</p>
<p><a href="http://helio.hlegius.pro.br/imagens/screen/db_aqua_studio.png"><img src="http://helio.hlegius.pro.br/imagens/screen/db_aqua_studio_peq.png" alt="[img] aqua studio" /></a><br />
(Clique para ver maior)</p>
<p>Vale lembrar que ele <strong>*no*</strong>  livre.  um <em>freeware</em> para fins educacionais.<br />
At a verso 4.x ele era freeware para fins educacionais ou testes. Nos demais casos,  uma ferramenta proprietria. Ele entrou na lista somente como um adicional.</p>
<p>Bom, infelizmente eu no conheo nenhuma outra ferramenta para gerenciar banco de dados. As que mais uso, eu citei neste post.  Conhece alguma ferramenta boa para uso ? Comente <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
No prximo post para continuar a srie, estarei falando das <em>extensions</em> do Firefox que auxiliam o desenvolvedor web.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Desenvolvendo para web: por onde começar afinal ?</title>
		<link>http://www.hlegius.pro.br/desenvolvendo-para-a-web-por-onde-comecar-afinal/</link>
		<comments>http://www.hlegius.pro.br/desenvolvendo-para-a-web-por-onde-comecar-afinal/#comments</comments>
		<pubDate>Sun, 15 Jul 2007 21:51:10 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Carreira]]></category>
		<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programação]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/desenvolvendo-para-a-web-por-onde-comecar-afinal/</guid>
		<description><![CDATA[Salve!
Se você é programador a mais de 2 anos, provavelmente não começou programando como todos essas coisas que ouvimos nas conferências ou que temos lido durante esses últimos tempos.
Alguns, talvez muitos dos programadores web são na verdade web developers, ou seja, uma mistura de programador com designer e como um bom developer você deve saber [...]]]></description>
			<content:encoded><![CDATA[<p>Salve!</p>
<p>Se você é programador a mais de 2 anos, provavelmente não começou programando como todos essas coisas que ouvimos nas conferências ou que temos lido durante esses últimos tempos.</p>
<p>Alguns, talvez muitos dos programadores web são na verdade web developers, ou seja, uma mistura de programador com designer e como um bom developer você deve saber que se não manter-se atualizado, você está fora da tecnologia, afinal, somos provedores de tecnologia de uma forma ou de outra =)</p>
<p>Hoje muitos desenvolvem nos moldes de meados de 1999/2003, ou seja tem as características:</p>
<ul>
<li>Programação procedural</li>
<li>HTML sem muita "frescura" para que fechar a tag body se ela não faz diferença mesmo ?</li>
<li>Estrutura do site em tabelas</li>
<li>Site for I.E only (Apenas para Internet Explorer)</li>
</ul>
<p>Mas é claro que você dá valor aos clientes, e também pretende continuar no ramo, então, você decide se atualizar, mas antes de fazer qualquer coisa logo vem a pergunta à mente: "Por onde começar ?"</p>
<p>Como diria nossa "ministra", relaxa e ... continua lendo!<br />
Não é nada fácil querer abraçar o mundo de um dia para o outro, então você precisa ir aos poucos! Vamos lá...</p>
<p><strong>1. Programação O.O</strong><br />
Trocando em miúdos: Programação Orientada à objetos. Essa técnica consiste em desenvolver uma aplicação mas visando o lado que tudo (ou quase tudo) é um objeto. Até para um programador que sabe o que é e usa todo dia se você perguntar o que é programação Orientada à objetos ele vai parar, pensar e talvez até indagar: "O que é mesmo Orientação a Objetos ?". Então, não se assuste com isso e também não precisa treinar a resposta para essa pergunta no espelho para ficar preparado quando te perguntarem <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bom, chega de papo... usando o "PHP procedural" como você faria para:</p>
<ul>
<ol>Acender uma lampada</ol>
<ol>verificar seu status</ol>
<ol>Apaga-la</ol>
<ol>Verificar novamente seu status ?</ol>
</ul>
<p>Com a programação procedural, poderia ser assim:</p>
<div class="igBar"><span id="lphp-22"><a href="#" onclick="javascript:showPlainTxt('php-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-22">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$status</span> = <span style="color:#FF0000;">"Desligada"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$status</span> == <span style="color:#FF0000;">"Desligada"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$status</span> = <span style="color:#FF0000;">"Ligada"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Acendendo a luz: Acendeu a lampada!&lt;br&gt;"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Estado atual da lampada: "</span> . <span style="color:#0000FF;">$status</span> . <span style="color:#FF0000;">"&lt;br /&gt;"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$status</span> == <span style="color:#FF0000;">"Ligada"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$status</span> = <span style="color:#FF0000;">"Desligada"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Apagando a luz: Apagou a lampada!&lt;br /&gt;"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Estado atual da lampada: "</span> . <span style="color:#0000FF;">$status</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Agora, com a programação O.O:</p>
<div class="igBar"><span id="lphp-23"><a href="#" onclick="javascript:showPlainTxt('php-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-23">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Tomada <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$TOMADA</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> acende<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">TOMADA</span> = <span style="color:#FF0000;">"Ligada"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#FF0000;">"Acendeu a lampada!"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> apaga<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">TOMADA</span> = <span style="color:#FF0000;">"Desligada"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#FF0000;">"Apagou a lampada!"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> estadoAtual<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">TOMADA</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Instanciando o objeto</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Esse objeto não precisa ser instanciado nesse arquivo, aqui é apenas um exemplo</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$tm</span> = <span style="color:#000000; font-weight:bold;">new</span> Tomada<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Acendendo a luz: "</span> . <span style="color:#0000FF;">$tm</span>-&gt;<span style="color:#006600;">acende</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">"&lt;br /&gt;"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Estado atual da lampada: "</span> . <span style="color:#0000FF;">$tm</span>-&gt;<span style="color:#006600;">estadoAtual</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">"&lt;br /&gt;"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Apagando a luz: "</span> . <span style="color:#0000FF;">$tm</span>-&gt;<span style="color:#006600;">apaga</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">"&lt;br /&gt;"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#FF0000;">"Estado atual da lampada: "</span> . <span style="color:#0000FF;">$tm</span>-&gt;<span style="color:#006600;">TOMADA</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>A saída de ambos no browser é a exibida abaixo:</p>
<p><img src="http://helio.hlegius.pro.br/imagens/screen/lampada_oop.png" alt="[img] resultado" /></p>
<p>Com O.O.P a mesma rotina ficou mais clara, mais organizada, e o principal: reutilizável! Apenas instâncio a Tomada() onde eu precisar e consigo acender/apagar as lâmpadas! <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><strong>NOTA:</strong> Destaque para a linha 27 e 29. Vejam que em ambas eu acho o status da lâmpada, porém, de formas diferentes. Tentem descobrir o por quê!</p>
<p>Infelizmente não posso ficar falando apenas de O.O.P, vamos partir para o próximo assunto!</p>
<p><strong>2. Organize seus dados com XML</strong><br />
Já ouviu falar de XML antes ? Acredito que sim.<br />
O XML (eXtendend Markup Language) tem toda uma história e tragetória por trás, porém, não é o foco aqui entrar nesses detalhes nem no histórico do XML. O importante é entender o que é, para que serve e como funciona. Tendo esses principios, você já poderá começar a definitivamente brincar com XML.</p>
<ul>
<li>XML é uma linguagem de marcação que armazena todo tipo de informação que você precisar.</li>
<li>Como já dissemos, ele serve para armazenar dados de qualquer tipo</li>
</ul>
<p>Um exemplo de uma informação no XML seria:</p>
<div class="igBar"><span id="lxml-24"><a href="#" onclick="javascript:showPlainTxt('xml-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-24">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"ISO-8859-1"</span> ?<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faqs<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span>Duvidas gerais<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span>O que é XML ?<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span>É exatamente isso que você vê!<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span>Duvidas gerais<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span>O que é XML ?<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span>É exatamente isso que você vê!<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span>Duvidas gerais<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span>O que é XML ?<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span>É exatamente isso que você vê!<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span>Duvidas gerais<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span>O que é XML ?<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span>É exatamente isso que você vê!<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span>Duvidas gerais<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/categoria<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span>O que é XML ?<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/pergunta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span>É exatamente isso que você vê!<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resposta<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faq<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faqs<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>A saída dele no browser seria algo como isso:</p>
<p><img src="http://helio.hlegius.pro.br/imagens/screen/exemplo_xml.png" alt="[img] modelo xml" /></p>
<p>Claro que para ficar interessante precisaria jogar um estilo nessa informação para ser exibida adequadamente e tudo mais. É para isso que existe o <strong>XSL</strong> (Outra coisa para pesquisar <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
<p><strong>3. xHTML. HTML mais extensível e mais dentro dos padrões</strong><br />
xHTML não difere muito do HTML que conhecemos há tempos. Ele tem <strong>algumas regras</strong> que sendo seguidas garatem que nosso documento estará sendo exibido adequadamente aos nossos visitantes/clientes.<br />
Alguns pontos interessantes:</p>
<ul>
<li>Definir um doctype</li>
<li>Escrever tags atributos e elementos em <strong>minusculo</strong>. < p > < /P > é errado!</li>
<li>Fechar todas as tags! < p >< /p > e < br / ></li>
<li>Usar o atributo alt para imagens. Afinal não são todos que acessam a net com browsers que renderizam imagens!</li>
<li>Tag's em ordem: < strong >< em >< /strong >< /em > é errado!</li>
</ul>
<p>Como ele não muda visualmente do HTML, não tem muito o que mostrar. É testar e acostumar-se com a prática.</p>
<p><strong>4. Tableless</strong><br />
O Tableless é uma metodologia de desenvolvimento, e não uma tecnologia ou ferramenta de trabalho como alguns ainda pensam. Há um bocado de motivos para usar o tableless nas suas aplicações, não vou focar nisso aqui, pois existem artigos que explicam muito bem isso! São exemplos:</p>
<ul>
<li><a href="http://www.tableless.com.br/desenvolvedor-retrogrado">http://www.tableless.com.br/desenvolvedor-retrogrado</a></li>
<li><a href="http://tableless.com.br/aprenda/faq/">http://tableless.com.br/aprenda/faq/</a></li>
</ul>
<p><strong>5. E muito mais...</strong><br />
Acha que acabou ? Pois bem, vamos citar mais algumas coisas:</p>
<ul>
<li>Frameworks de desenvolvimento</li>
<li>Javascript / DOM e Ajax</li>
<li>MVC</li>
<li>Design Patterns</li>
<li>CSS, XSL</li>
<li>Site Multiplataforma. Para este, vale a dica seguir as <a href="http://w3c.org">especificações W3C</a> de desenvolvimento.</li>
</ul>
<p><strong>Ufa! Que tal concluir o post ?</strong><br />
Ok! Ficou cansado com o <em>tour</em> ? Ficou preocupado ? Não se espante! Siga a ordem que apresentei aqui, ou qualquer outra ordem que prefira, só não queira aprender tudo de uma vez da noite para o dia, porque neste caso, você não vai conseguir entender como as coisas funcionam!</p>
<p>Bom estudo ! <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/desenvolvendo-para-a-web-por-onde-comecar-afinal/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ferramentas livres que auxiliam o desenvolvimento web. Parte 1</title>
		<link>http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-1/</link>
		<comments>http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-1/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 17:10:29 +0000</pubDate>
		<dc:creator>hlegius</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Dia-a-dia]]></category>
		<category><![CDATA[Software livre]]></category>
		<category><![CDATA[Programação]]></category>

		<guid isPermaLink="false">http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-1/</guid>
		<description><![CDATA[Salve!
Esse post é o primeiro da série: Ferramentas livres que auxiliam o desenvolvimento web.
Minha idéia é relatar em alguns posts, ferramentas de todos os tipos que auxiliam o desenvolvimento do programador web. Segue o cronograma atual da série:

Editores / IDE's de desenvolvimento
Gerenciadores de banco de dados
Plugins para o Mozilla Firefox
Gerenciamento de projetos e tarefas do [...]]]></description>
			<content:encoded><![CDATA[<p>Salve!</p>
<p>Esse post é o primeiro da série: <strong>Ferramentas livres que auxiliam o desenvolvimento web</strong>.<br />
Minha idéia é relatar em alguns posts, ferramentas de todos os tipos que auxiliam o desenvolvimento do programador web. Segue o cronograma atual da série:</p>
<ul>
<li>Editores / IDE's de desenvolvimento</li>
<li>Gerenciadores de banco de dados</li>
<li>Plugins para o Mozilla Firefox</li>
<li>Gerenciamento de projetos e tarefas do dia-a-dia do programador web</li>
</ul>
<p>Hoje, é o primeiro post da série e pretendo destacar aqui ferramentas voltadas à <strong>plataforma Linux</strong>, afinal, é nela que eu trabalho diariamente!<br />
Importante lembrar que eu não conheço todos, afinal são inumeras as ferramentas para esse tipo de atividade. Minha intensão é relatar a minha experiência ao longo dos meus <strong>3 anos</strong> como programador web e mais de <strong>2 anos</strong> como usuário assíduo do Linux.<br />
* Dia 09/07 completarei 3 anos como programador web. Presentes? <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>1. Editores / IDE’s de desenvolvimento</strong></p>
<p><strong>Peso leve</strong><br />
Nesta categoria, já experimentei algumas. Umas mais conhecidas não só por programadores, mas também por administradores Linux, enquanto outras, voltadas ao desenvolvimento web em especial.</p>
<p><strong>VI</strong>. Realmente uma fantástica ferramenta para editar textos e scripts dos mais variados tipos. Há inumeros materiais sobre sua utilização na Internet.<br />
<strong><em>Caracteristicas</em></strong>: leve, prático, alta disponibilidade(vem por padrão em inúmeras distribuições Linux), possui sintax highlight, possibilidade de editar mais de um arquivo por vez (mesmo sendo em modo texto).</p>
<p><strong><a href="http://bluefish.openoffice.nl/">Bluefish</a></strong>. O editor do peixe azul, também é outro editor super leve e bem completo (para sua ocupação na memória). Este por sua vez, já é gráfico e usa <a href="http://pt.wikipedia.org/wiki/GTK">GTK</a> e vem por padrão no ambiente <a href="http://www.gnome.org">Gnome</a>.<br />
<strong><em>Caracteristicas</em></strong>: Exibe a árvore de arquivos do sistema operacional facilitando a abertura e gerenciamento dos arquivos; Sintax highlight; Multi-arquivo (abre mais de um arquivo por vez)</p>
<p><strong><a href="http://www.gnome.org/projects/gedit/">Gedit</a>, <a href="http://kate-editor.org/">Kate</a></strong>. São dois editores. O Gedit está por padrão no ambiente <a href="http://www.gnome.org">Gnome</a>, enquanto o Kate está por padrão no ambiente <a href="http://www.kde.org">KDE</a>. Ambos possui recursos similares, por isso juntei ambos numa mesma categoria.<br />
<strong><em>Caracteristicas</em></strong>: São dois editores "leves"* e muito completos. Conseguem editar arquivos diretamente da rede, por exemplo, de um servidor FTP; Possuem integração com compiladores, pertimindo que você edite o arquivo e já compile e rode para ver como ficou; Sintax highlight para várias linguagens; Folding; Permite criar projetos**<br />
* Não são leves se considerarmos que é necessário carregar o ambiente padrão do editor para usa-lo. Mas considerando o editor em si, ele é leve <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
** Apenas o Kate permite pelo que eu me lembre.</p>
<p><strong><a href="http://www.nvu.com">NVU</a></strong>. Um editor simples, porém bem completo. Ele é um dos poucos para Linux que permite que você use o recurso <em>clique-e-arraste</em> para criar páginas simples em HTML. De acordo com o <a href="http://www.nvu.com">site oficial do projeto</a> ele permite a publicação do projeto em servidores FTP na web.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>Peso pesado</strong><br />
Os editores "peso leve" ajudam no desenvolvimento de aplicações rápidas, coisas simples. Porém, ao iniciarmos um projeto maior, sentimos falta de mais recursos, presente apenas em editores "peso pesado". Vamos a eles!</p>
<p><a href="http://quanta.kdewebdev.org/screenshots//shot2.png"><img src="http://helio.hlegius.pro.br/imagens/screen/quanta.jpg" alt="[img] quanta plus" /></a><br />
(Clique para ampliar)</p>
<p><strong><a href="http://quanta.kdewebdev.org">Quanta</a></strong>. Um editor, na verdade, uma quase IDE para desenvolvimento web. Ele vem junto com o KDE desde que instalado o pacote <em>kdewebdev</em>. Junto com o <strong>NVU</strong> ele também possui o recurso <em>clica-e-arrasta</em> para confecção de páginas HTML.</p>
<p><strong><a href="http://www.kdevelop.org/">Kdevelop</a></strong>. Este é uma IDE para desenvolvimento em várias linguagens, inclusive PHP. Possui vários recursos, como controle de projetos, sintax highlight, integração com outros aplicativos como compiladores. Não tenho muita experiência com ele, pois não usei ele por muito tempo por ser meio "desfocado" das linguagens web. Mas conheço programadores web que trabalham com ele muito bem.</p>
<p><strong><a href="http://www.aptana.com/">Aptana</a> / <a href="http://www.eclipse.org/proposals/php-ide/">Eclipse PHP IDE</a></strong>. O Aptana é baseado no Eclipse IDE. O diferencial do Aptana é seu foco 100% para aplicações web, mas especificamente Javascript/xHTML, Ajax e PHP. Os recursos básicos de ambos são identicos, a não ser o foco maior no desenvolvimento web pelo Aptana. Porém, o Eclipse com Plugin do PHP, fornece um excelente ambiente para criação web.<br />
<strong><em>Caracteristicas</em></strong>: </p>
<ul>
<li>Trazem plugins que permitem conectar a servidores CVS/SVN (inclusive tem um <a href="http://www.hlegius.pro.br/gerenciando-projetos-com-subversion/">post meu falando do Eclipse com SVN</a>)</li>
<li>Publicação online via FTP</li>
<li>Testes usando servidores locais (Apache, LightHTTPd...)</li>
<li>Gerenciamento de Tasks (usando a tag reservada @todo)</li>
<li>Sublinha possíveis erros de sintaxe durante a programação</li>
<li>Folding</li>
<li>Auxilia na aplicação de patch's</li>
<li>Traz no "output" a linha de métodos / classes criadas e disponíveis no projeto</li>
<li>Possui um "Debugador" interno (requer uma engine para debug no PHP, tipo XDebug)</li>
<li>Traz o manual de métodos do php, para auxiliar na programação. (Exemplo: você digita strlen e pressiona Ctrl + barra de espaço, ele traz os parâmetros requeridos pela função)</li>
<li>Dentre outros inumeros recursos</li>
</ul>
<p><strong>Para finalizar</strong> a dica é a seguinte: teste todos que puder. Entre no site dos projetos, veja screenshots baixe e teste ele por alguns dias. Eu fiz minha escolha: Eclipse PHP IDE para projetos de médio/grande porte; Para edições rápidas, eu uso o Kate ou Gedit, isso vai variar de acordo com o ambiente gráfico que vou estar utilizando. Como atualmente <a href="http://www.hlegius.pro.br/review-monitor-samsung-940b-plus-19/">estou usando KDE</a>, então estou indo de <strong>Kate</strong> para leves edições.</p>
<p><strong>No próximo post...</strong><br />
Estarei dando continuidade a série: <strong>Ferramentas livres que auxiliam o desenvolvimento web</strong> com a temática: <em>Gerenciadores de banco de dados</em>.</p>
<p>Não deixe de participar deixando seus comentários, dicas e sugestões aos demais leitores <img src='http://www.hlegius.pro.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hlegius.pro.br/ferramentas-livres-que-auxiliam-o-desenvolvimento-web-parte-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
