« first day (673 days earlier)      last day (4289 days later) » 

5:00 PM
just send the second bookmark to your phone
 
saving this for later use.
 
hi dears
how i can render tags in string :
{IMG:'http://www.example.com/image.jpg',TITILE:'cooking cake'}
to :
<img src='example.com/image.jpg' title="cooking cake" />
 
yes , you can, you have my permission
 
yes
 
here is the rub : you will have to use some sort of regular expression , because, according to jsonlint.com, the {IMG:'example.com/image.jpg',TITILE:'cooking cake'} is not a valid JSON string
 
5:11 PM
@Erfan You can do it
 
no
json is not good for me
 
i have create custom tag
how i can explode this tag use regular expression ?
 
@Erfan Here you go, Good luck!
 
you guys deal with it , i have wasted already enough time on IAP today
2
 
5:13 PM
@Donut tanX
i not proffecional for write a regular expression command for preg_much Or ... regular expression functions
 
I don't understand, If you know that you may use Regular Expresions, and you say that you are not good at them, what stops you to become better?
 
yes but ...
 
php manual isn't a good place to learn regular expressions
 
@Erfan but?
 
@meze yes ...
i love you write me one line command for explode this tag use regular expressions for preg_match ?
:D
 
5:22 PM
@Erfan write it yourself, we can help to make it work. Check out preg_replace to learn how to use that function. For your expression replace the dynamic parts with (.*) and, then, you can specify $1 and $2 in the replacement argument.
 
fuk , i cannot decide again
 
(.*) ok ... is good way for start lean in : regexr.com?31sio
 
lets pick some fresh brain ...
@meze , how do you handle validation of parameters in domain object ? do you use separate methods for each domain object , do you have shared ones in the superclass or do you inject a validator instance, which contains shared methods ?
@webarto , @LeviMorrison and @cspray could pitch in too ...
 
@meze tanX ... You is good techer :D ... pls check my code : regexr.com?31sio
 
@tereško This is actually something I've thought quite a bit about. I would probably wind up going with a validator instance I inject into the domain object. I like the idea of keeping my validation rules all set in one place instead of scattered throughout n domain objects
Of course I suppose if the validation is sufficiently complex and unique enough that maybe it doesn't fit a generic validation rule
And something more specific is in order
 
5:29 PM
@Erfan switch to the replace tab. ok the regexp is {IMG:'(.*)',TITILE:'(.*)'}
 
@meze not worked for me : regexr.com?31sir
ok
 
And I suppose subclassing out would keep it in one place. But, I'd rather inject the instance
Maybe I like all your rules except one, I can extend your validator instance without having to worry about inheriting all the other stuff that goes along with it and override your one method
 
you can take the symfony2 validator approach and shove your rules inside the domain object but have the validator somewhere in the service layer @cspray
 
lol, i should have read earlier,. the answer i am looking for is in the tut..crap.
 
@Lusitanian This is very true as well
 
5:34 PM
honestly that's the method I prefer, it makes the most sense to me
 
naah , external validatior seems like a bad idea
 
I prefer the symfony2's idea too. You define rules in annotations or config files, then use Validator service to validate domain objects.
 
because i want to validate parameters when setters are used
 
@tereško ahh good point
 
@tereško you'll never achieve that
 
5:36 PM
huh ? why not ?
 
a domain object can simply expire - no setter is used but you have an invalid domain object
 
what do you mean by "expire" ?
 
silly example. another: the object has a reference to another object that has been removed after the object was created
 
i don't see how this can become problem , it's not like php has a persistent model
 
it's not a big problem. It just doesn't matter when and where you validate domain objects
with a service or in setters
i thought you wanted to validate an object in setters because you didn't want to have an invalid object in the memory
 
5:42 PM
no , when domain object becomes invalid, i want to save the error state ( in session mostly )
 
hm then why setters?
 
$object->setBlah('blih'); if($object->isValid()) { // blah }
 
yes , but in my case :
public function isValid()
{
    return count($this->errors) === 0;
}
 
try { $object->growBy("400 inches"); } catch (HumanHeightException $e) {}
@tereško i see
 
$validator->isValid($object);
 
5:45 PM
also , i try to keep to "Tell, Don't Ask" rule of thumb as possible
 
$validator->validate($object);
;P
 
and this requires validator to have complete knowledge of objects structure
 
$validator->validate(@meze);
 
which naturally leads to myriads of setting in configuration
 
indeed. but that complexity will be hidden in the validator
 
5:47 PM
Well, I think the problem is in the name of the validator instance method
 
that's kind of where the concept of annotation metadata comes into play
@Validator\Range(min=-10, max=10)
 
i really don't like, when words "complexity" and "hidden" are in same sentence
 
i don't like annotation
 
The validator shouldn't need to know internal object structure
 
5:49 PM
because you can't say what validation rules are of an object without scrolling tons of code (if you have large domain objects)
 
@cspray it's like $router->route( $request );
so basically there are two issues :
- should domain object contain all the validation rules
- should the domain object validate itself or should it be validated by some external entity
 
@cspray it has to
 
@meze Why?
I think the domain object needs to validate itself. If you rely on some external entity the first time somebody adds a domain object without using that external entity you have a rogue invalid domain object
 
i do believe it's arguable
 
But doesn't it violate SRP? validations rules are a reason for change
 
5:53 PM
@Lusitanian Well of course. Just like everything in software development
 
@meze That could be the case but as teresko mentioned earlier if you have a setter then once they get the object validated through the external entity they just set invalid data to it
 
@cspray because the validator should know properties of an object that should be validated
@cspray and i as i mentioned: an object can become invalid after you used a setter
so it doesn't solve this problem
 
If the validator is that tightly coupled to the object it is validating why not just store it in the object?
If the validation was done internally it could solve this problem. If the data is invalid it never sets the value
 
dependencies are bad
 
5:57 PM
So is invalid data
 
@meze here, every function called on an object that mutates its state
should re-validate the object
then how is it going to become invalid?
 
And I don't mind dependencies when they're explicitly declared. Oh, hey look to create a domain object I need to make sure it can validate some stuff. Ok, hand it this service
 
@Lusitanian you have a rule "a parent must exist in the databse": $object->setParent($parent); $db->remove($parent); is $object invalid or valid?
 
Why should domain object validation rules correspond to the database?
 
@Lusitanian why not?
 
5:59 PM
@meze , data integrity should not be checked at validation , that should be handled by object which handles the storage
 
and it's just an example
 
They're a separate part of the model layer.
 
@tereško suppose your storage is nosql
 
I'm not agreeing/disagreeing with either of the methods (validator service/internal validation): there are certainly flaws with both though.
 
without such a feature
 
6:00 PM
You can check data integrity within your data mapper (or whichever sort of layer you use for persistence)
 
@meze , then your storage object would have to check it manually , without relaying on UNIQUE constraint
 
alternatively, you could use a super::$tatic
 
data mapper may recheck before persisting
it would be an exception and shutdown in my application if a foreign key doesn't exist
bad example.
 
the example, that i can see is: if you are assigning simple values through references, but that would be a bad idea to begin with
 
@cspray "If the data is invalid it never sets the value" what if a rule includes two properties?
 
6:13 PM
"value was not set" might be a data integrity problem , or it might be a valid situation
and if validation require two values , then when you set the first one , it set and error , and when you set second value it removes the error
 
yes, data integrity problem is solved by the datamapper layer or the database. it has nothing to do with validation of domain objects
@tereško @cspray suggested to never set invalid value
 
i don't see the point in that
public function setEmail( $email )
{
    $this->email = filter_var( $email, FILTER_VALIDATE_EMAIL );
    if ( $this->email === FALSE )
    {
        $this->setError('email', User::ERROR_FORMAT ) ;
    }
}
you should not prevent setter from setting value , but it should be know that there is a problem
just like you do not kill the student, when one gives you a wrong answer
... hmm .. i think this metaphor didn't work out all that well
 
one thing that i don't like - every domain object has to extend a base object with validation methods. And if you have references that are validated too, you'll need to patch owner::getErrors
 
well , that was the original question
 
7:13 PM
@tereško thanks for posting link to this article. Though I didn't grasp all the parts fully, it is the most decent read I've ever tried. Thank you
 
which is quite sad , because it has pretty major faults
and i hate when bootstrap file starts to grow uncontrollably
 
@tereško Do you mean static routes?
 
no , not that , routes are defined in JSON file
 
@teresko is there any framework which follows the pattern described in the aricle?
 
my current issue are model layer structures which are part of framework's namespace
@hookman , no , there isn't
and as i already said , there is on major issue with that article
author binds the controller to the view
 
7:24 PM
@tereško He said he needs that to have a callback to the Controller in the View
 
yeah , which is the part that where it all goes wrong
 
@tereško Don't have enough knowledge to discuss this)))
gotta go
 
7:50 PM
not sure if doing it right :
namespace Fracture\DomainLogic;
class Session implements Initializable, Unique
{

}
wasn't there a SPL session handler ?
 
they added it in php 5.4
 
@meze можешь на русском объяснить что есть Domain в контексте Domain Entity?
 
yeah , saw it already , but it does not do what you would expect
@hookman if you get this explained in russian , you wont be able to google the terms
and terms Domain and Domain Entity come from project management , the planning phase
and yes , i can read russian =P
 
^^
@tereško Should I read this?
Domain-driven design (DDD) is an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts. The premise of domain-driven design is the following: * Placing the project's primary focus on the core domain and domain logic * Basing complex designs on a model * Initiating a creative collaboration between technical and domain experts to iteratively cut ever closer to the conceptual heart of the problem. Domain-driven design is not a technology or a methodology. DDD provides a structure of practices and termin...
 
8:05 PM
honestly , i am not sure
 
> Domain: A sphere of knowledge (ontology), influence, or activity. The subject area to which the user applies a program is the domain of the software.
 
yes , the definition fits , but i am not sure if it is all that useful to you
 
"Every software program relates to some activity or interest of its user. That subject area to which the user applies the program is the domain of the software."
 
most love recursive definitions
 
@hookman на rutracker есть книга Предметно-ориентированное проектирование от Эванса на русском, там можно почитать.
but DDD is a bit complicated thing and I've never seen anyone using it in PHP
 
8:17 PM
@meze english please
 
@meze Thanks for clarifying.
 
@hookman , thought IMO this one might be a better book
@PeeHaa , what ? you cannot read russian ?
 
@tereško ^^
 
@tereško Well I see rutracker so I suspect its about downloading something :) But that's all the russion I know ;0
 
lol
 
8:22 PM
@tereško i gave the same book but in russian
 
author would be the same .. hmm ...
you might be correct
 
Evans = Эванс
authors are translated too
 
yeah .. glossed over the author for some reason
 
@meze Reading it in original is not a problem. I asked about Domain, because I frequently see it in this chat, and kinda unserstand what it means, but I had some doubts...
 
it's hard to explain
i would say that domain is all the information ( that include rules, ideas and principles ) which is tied to particular subject
usually , when you are making a project , the subject is some sort of business endeavor
 
8:30 PM
or the knowledge of area that the software used in. and the domain is captured in domain objects
 
@tereško I think this will be clear for me after understanding of the model layer (Domain Objects, Data Mappers, Services), and how it's components communicate with each other.
 
@meze , i would say that it is mostly captured in domain objects
@hookman , that's not how/when i understood it
 
@tereško why?
 
@meze , because interaction between domain objects is part of domain logic too
 
@tereško Anyway, I think it's early for me to study that area
I'll stick with PHP: Object Oriented Solutions, and then'll see, what to do next
 
8:36 PM
that seems like a good plan
i would suggest SQL Antipatterns as next one in line (assuming that you already understand basics of SQL)
to you too , @meze, if you have not read it already
 
read it today ;)
 
good for you
 
@tereško I've already had an experience of "mastering the depth of :anythinghere" without basic knowledge of it and understanding why it is used. Having that experience I decided to go step by step.
 
good for people who just learned sql but useless for intermediates
 
now you will be able to get annoyed on questions too
and i really depends on what do you mean with "intermediates"
 
8:41 PM
I was advised this book. Any opinions?
 
good evening :)
 
its not bad for starting to learn MySQL
 
I understand relation algebra, SQL, normalization, optimization, but when it comes to complicated queries I struggle ;P
 
that is "basics"
 
complicated queries = queries with tricky joins, grouping
 
8:45 PM
i am not sure the how you ended up at the "good for people who just learned sql but useless for intermediates" conclusion
because IMHO , the "SQL Antipatterns" book is aimed at intermediate/advanced level developers
 
@tereško This book will help me to fill the spaces... btw, added SQL Antipatterns to my list, thx
 
because I already knew almost all in that book and was thinking 'who would do like that?' when reading the description of antipatterns...
that is not basics, it's lack of experience
and intermediate/advanced level developers should already know what is written in that book
 
beginner -> intermediate -> advanced -> professional -> writes books
 
-> Jon Skeet
 
naah .. Skeet is just an extreme case of rep-whore
 
8:54 PM
Is there anyone here who has tried the CI user guide/tutorial example that uses a news system?
I was able to get to the second page just fine, but after following (and double/triple checking re-creating the files) - I keep getting ERROR 500 when trying to surf to docroot/index.php/news

Any ideas what could be wrong and where I could find what's going wrong?
 
he writes good books though
 
@KoenGeeraert usually 500 is caused by some type of endless loop
start by looking at error/access logs
if that does not work , start commenting out some code
 
Aug 16 at 19:59, by SomeKittens
codeigniter advice: Don't use codeigniter
 
php documentation at it worst
 
hii:D
 
9:03 PM
the function has no comments!
 
quickly, type a comment
/* 5 seconds later */
First!!!111
 
@tereško I still can't get that controller callback part in the article. You said it's bad idea. Which is responsible for generating anchors?
 
they didn't think that someone would need docs for such functions ;)
 
@hookman honestly , I think that's the wrong part here. URL generation should be responsibility of routing mechanism, and it should not be related to the controllers.
 
What's everyone's opinion of empty interfaces? Essentially just implementing them to tell the client code "I'm going to be fulfiling this role" and allow for proper type hinting. On one hand it feel s better to typehint things just to be more strict, on the other, an empty interface seems quite pointless.
 
9:11 PM
ActiveRecord : worst thing that RoR did to web development
@TomB , i am using an empty interface which indicated that domain objects should be unique within the model layer
it's used in the factory class
i don't really see it as a problem , since interfaces are there to indicate "what can you do with this object"
 
Indeed, but there are pros and cons. If they are truly empty, why restrict your application by enforcing them?
 
not sure how they would be restrictive ... care to elaborate ?
1 hour ago, by tereško
namespace Fracture\DomainLogic;
class Session implements Initializable, Unique
{

}
in this case Unique is an empty interface
 
agree. interfaces indicates how you can treat objects and it's not only method calling
 
Once you have a function that is defined as function foo(MyInterface $bar) {} you are restricting what can be passed to foo(), when really there's no need to make that distinction
because $bar does not need to support any specific methods
 
huh ?
why would to use an empty interface in such situation ?
the interfaces in such methods are used to implement ISP and DIP
 
9:17 PM
If you're never referencing the fact that the interface is used outside the class which is implementing it, what's the point?
 
just omit type hint
;p
 
@TomB , what are you talking about ?!
 
@tereško lmfao!!
 
some people ask really weird questions, or believe Stackoverflow is the support forum for every PHP application or script...
 
@TomB the method declartion doesn't matter here. it would be function foo(ConcreteClass $bar) {} without an empty interface. which is worse
 
9:22 PM
@tereško, if the interface is only ever referenced in class definitions, what is the point in using it? In your "Unique" example I'd argue it's poor separation of concerns. Why should the session class define enforced uniqueness? It's the responsibility of the code which is initializing sessions to enforce that, surely? I assume "unique" is referenced in an instanceof check somewhere?
 
it is used so that factory ( class which initialized the instance ) can recognize that it should enforce the uniqueness of it. And yes, it is used with instanceof
 
@meze, but why not just omit the type hint all together function foo($bar) {}or function foo(object $bar) {} if php supports hinting "object"
 
@TomB it's another question ;p you still can implement an empty interface
 
Yeah, you can implement an empty interface, my question was should you?
 
yes if you want to
;)
there's no rule
 
9:26 PM
i already provided example where it makes sense
at least to me
then again , i am still learning all this OOP stuff
anyway , i don't see any other way to implement this sort of behavior
 
To me, a class implementing a method which enforces rules on parent objects seems like a poor separation of concerns
 
and the interface might not stay empty forever
 
M. Fowler uses interface Null {} for Null Object pattern
 
@TomB what ?
 
Simple, just have a database of class names which need to be unique in the factory. I bet there's not many at all! If you're using a Dependency Injection Container the uniqueness should be defined there anyway.
 
9:30 PM
> favor convention over configuration
 
agree with Tom B. it's not clear what your Unique interface means
i thought that you persist it in the database
and it's unique there
 
no , it is there so that factory know what i should make only one such structure
 
other people won't know it ;(
 
Session instance in my code is type of mapper
 
By letting your Session class definition control how the factory works, the Session class essentially contains logic telling the factory how to behave. This breaks encapsulation, the session knowns the implementation details of the factory
 
9:32 PM
hmm ... nevermind , all mappers should be initialized only once
 
but i guess it's just a bad name. SingleInstance would make more sense
 
your session class is enforcing rules on how it is used. It's no longer self-contained. Either the session class should enforce this by itself, or ideally, not worry about its uniqueness and leave it to the outside world to decide how/when it's used.
 
@TomB , how did you conclude that session instance knows implementation of factory ?
the idea for the empty interface is to let factory know of the nature of object which it created
that IS the goal of interfaces
 
The session implements "Unique", which has zero meaning to the session itself. It's used higher up. Session knows it's going to be created by something that is going to check whether it's flagged unique or not, which means it knows of the way the factory is implemented. Further to that, if the Session is initialised anywhere other than the factory, uniqueness is not preserved.
 
it is funny how some people prefer to create one more duplicate for a question that has already been answered many times: stackoverflow.com/questions/12030143/…
 
9:36 PM
all interfaces hae zero meaning to class itself
 
no, they don't. Ususally they force the class to implement some methods
 
no, interfaces DESCRIBE what methods class has implemented
the describe the behavior of the instance
 
Well, whichever way you look at it, they enforce a strict API
empty interfaces do not.
 
interfaces are not for enforcing anything
 
@tereško i'd say what you can do with the instance
 
9:40 PM
I think that's answered my initial question though, empty interfaces hint at a poor separation of concerns. By tagging classes with an empty interface that's essentially just a label, it breaks encapsulation because the child object is defining how the parent must use them... which is backwards.
 
what ?
what has this to do with extending ?!?
 
btw php has an empty interface too: Traversable
 
Interesting, but do any classes ever implement that or is it only used by other interfaces?
 
In fact, the manual says it can't be implemented alone.
 
9:44 PM
@TomB right. but you can use it with instanceof and for type hinting
 
@TomB , why did you begun to talk about parent and child classes ? How is inheritance related to this ?
 
anyway we don't understand what you're trying to say
and if we're on interfaces. Is it normal to define constants in interfaces? It works but feels strange.
 
@TomB , oh .. and while you are online : why the hell in you MVC tutorial View requires an instance of Controller ? While controller does not require a view ( which state i should be changing )
@meze i don't see a point in this
 
I didn't mean parent/child classes sorry. I meant parent/child in an aggregation sense. In your session example, the factory is creating a "session" object, and presumably doing if ($className instanceof Unique) {}. By doing this, the session class knows the implementation details of the factory method which is creating it. The session knows that the factory is going to check it for uniqueness.
 
actually the Session class does not depend on it
 
9:49 PM
@tereško the problem is i have a few classes that implement one interface. and they all use a magic string
 
you mean __toString() ?
 
@tereško because the View should be usable with a substituted controller. Which ever way you do URL routing, the View needs to know which controller to pass events back to. You can hard code URLs in the view, but this looses a lot of flexibility
 
no. "Unique values with unexplained meaning or multiple occurrences which could (preferably) be replaced with named constants"
 
@TomB , the generation of URL should be dome by routing mechanism , not by the controller
i guess i'm just having problem with fact that your MVC implementation start from view
 
I'd argue it should be done as part of the view, not the controller or routing mechanism. Each link in a view will eventually end up at a controller action. But in order to create the link, the view needs to know which controller (and which action) it's linking back to
 
9:54 PM
@TomB a view don't need to know that
 
actually there's no View in web application.
 
so how would i generate http://who.cares/username URL ? For viewing user profile
 
It needs to know what route it should use and what params should be supplied
 
@meze , that's a lie
 
@tereško not a lie.
 
9:55 PM
There is most certainly a view in web applications.
 
and what is it? a template?
 
@meze views are instances which handle the presentation logic. Just because most of frameworks pretend that there are no views and dump the presentation logic in the "controller" does make it true
 
To generate a URL, a URL generating function (Which follows the same URI structure rules as the router) would be passed a controller, controller action and relevant parameters.
 
@TomB nice answer :)
Please see this answer people ;) stackoverflow.com/a/9560507/508666
 
@tereško and what is the presentation logic in web applications?
a template that is parsed by template engine and we have just a string that we need to send back to the user ;)
 
9:58 PM
@meze , what format of output to use , what headers do i need to send , from which templates do i assemble the response , what information do i need from model layer to use those templates
 
does anyone else think that: stackoverflow.com/questions/12030334/… should be using objects instead of arrays?
 

« first day (673 days earlier)      last day (4289 days later) »