A refuting piece of evidence from the guy who created nulls. How cool is
that?!  :)

On Tue, Nov 17, 2009 at 1:20 AM, David Pollak <feeder.of.the.be...@gmail.com
> wrote:

>
>
> On Mon, Nov 16, 2009 at 9:01 PM, DMB <combust...@gmail.com> wrote:
>
>> >> that it's not null--which is a source of many bugs
>>
>> After a bold statement like this, one can't help but wonder how
>> programmers manage to ship software in all the other languages. :-)
>> Come to think of it, after working on a couple of pretty large ASP.NET
>> projects (~50 devs), I haven't once seen a bug which was caused by the
>> semantics of retrieving the cookie or URL parameter values. I'm not
>> saying the Box thing doesn't have its uses, I'm just saying that in
>> this particular case it's a pain in the ass and overkill.
>>
>
> Before judging, spend a month or two writing idomatic Scala code rather
> than fighting with it.
>
> In your example, I reduced the lines of code, made your code more logical
> and reduced the McCabe complexity (see
> http://en.wikipedia.org/wiki/Cyclomatic_complexity).  The higher the
> McCabe complexity, the more defects there are in software.
>
> So, even in a trivial 20 line program, using the Scala idioms shortens code
> and generally makes code easier to read and easier to maintain.
>
> And we're not the only ones who think null is a problem... the guy that
> invented null thinks it's a huge problem:
> http://qconlondon.com/london-2009/presentation/Null+References:+The+Billion+Dollar+Mistake
>
>
>
>>
>> On Nov 16, 2:40 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
>> > As others may have said, the difference between a Box and a value that
>> may be null is that both may or may not contain what you want it to have;
>> but in one case the compiler lets you assume that it does--that it's not
>> null--which is a source of many bugs.
>> > Programming presents a tension between type safety and conciseness, and
>> Scala does an amazing job of being extremely type safe and extremely
>> concise. But type safety comes first.
>> >
>> > -------------------------------------
>> >
>> > DMB<combust...@gmail.com> wrote:
>> >
>> > I guess that could work, but why go to such lengths where there are
>> > much more straightforward solutions available? What do for
>> > comprehensions buy you in this case? I mean, 99% of the time, when I
>> > want to check for a cookie, I don't need the cookie itself or any of
>> > its properties. I need its value, or null if there's no cookie. Why
>> > not do something a-la RoR:
>> >
>> > S.cookieValue("cookieName")
>> >
>> > or a-la ASP.NET:
>> >
>> > val c = S.cookie("cookieName")
>> > if(c != null) {
>> >    val v = c.value
>> >
>> > }
>> >
>> > Or, indeed, both?
>> >
>> > On Nov 16, 1:22 am, Sergey Andreev <andser...@gmail.com> wrote:
>> >
>> > > Hi,
>> >
>> > > For-comprehensions could help you out:
>> >
>> > > for{
>> > >   cookie <- S.findCookie(cookieName)
>> > >   value <- cookie} doSomethingWithValue
>> >
>> > > Regards
>> >
>> > > On Mon, Nov 16, 2009 at 12:07 PM, DMB <combust...@gmail.com> wrote:
>> >
>> > > > When I call findCookie it returns a Box. Then, the value on the
>> cookie
>> > > > itself is also a box. Hence a ruby one-liner turns into something
>> > > > like:
>> >
>> > > > val cookie = S.findCookie(cookieName)
>> > > > if(cookie.isDefined) {
>> > > >     val cookieVal = cookie.open_!.value.openOr(null)
>> > > >     // Do something with the cookie value
>> > > > }
>> >
>> > > > This is very ugly, so I'm guessing I'm doing something wrong, but
>> try
>> > > > as I might, I could not find any examples that would look even
>> vaguely
>> > > > "right" to me.
>> >
>> > > > Why can't findCookie return a simple, unboxed HTTPCookie object or
>> > > > null if cookie is not found?
>> > > > Why does the value inside a cookie need to also be Box'ed?
>> >
>> > > > For the sake of comparison, here's how you do the same thing in RoR:
>> > > > v = cookies["cookieName"]
>> > > > // Do something with the cookie
>> >
>> > > > or ASP.NET:
>> > > > var c = Request.Cookies["CookieName"]
>> > > > if(c != null) {
>> > > >   var v = c.Value
>> > > >   // Do something with the cookie
>> > > > }
>> >
>> > > > I fail to see why Lift should be more complicated.
>> >
>> > > > This is with Lift 1.1 M7
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Lift" group.
>> To post to this group, send email to lift...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/liftweb?hl=.
>>
>>
>>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
>
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=.
>



-- 
Jack Widman

co-founder / cto,  Authoritude, Inc.

203-641-9355

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=.


Reply via email to