Welcome Guest, Not a member yet? Register   Sign In
MeNeedz Cloud
#11

[eluser]davidbehler[/eluser]
It's a libary for CI and therefor nothing is wrong with using CI code!

And what do you mean by saying "functions are way too long"?
They don't need many parameters and what can I do if some processing is needed?
#12

[eluser]meteor[/eluser]
well, CI can use any library, you know it don't you Wink)
So it is better to write independent code which can be tested with phpunit, you probably know how bad testing in code igniter really is, in my opinion you should give yourself a chance to test your code properly and use correct tools for the job ... I found it difficult to test your code with phpunit. Functions are too long and that's what it means. It is better writer four or five short functions to make it easier to test than put everything into one big piece. Testing such code is very difficult, time-consuming and i takes off all the fun from testing of code to me. So, if much processing is needed, you should split your code into small pieces and test them thoroughly to ensure that everything works as expected ... Changing one small function is much more easy than changing 40 lines of code ... believe me.

Regards
#13

[eluser]davidbehler[/eluser]
I usually only use smaller functions if a certain functionality is needed in multiple functions and as far as I'm concerned that's not the case here.

I see why smaller functions are easier to test, but the functions in my small library are not that big and shouldn't pose much of a problem.

I have just looked into the library and actually it's only CI dependent because I get an instance of the CI object but it's never actually used. So if you remove the
Code:
$this->CI =& get_instance();
you can easily use the library in whatever project you want and use phpunit to test!

I will upload an updated version later!
#14

[eluser]davidbehler[/eluser]
You can get the new CI independent version from here: http://www.davidbehler.de/download/cloud.rar
#15

[eluser]stef25[/eluser]
The CI version works great for me.

One issue: where do you use the initialize() function? I have what's below and the cloud comes out fine, only the font sizes I try to initialize are ignored and they remain between 10px and 30px, even if I comment out $this->clear() in initialize() (Doesn't that always reset?).

Code:
function tag_cloud($tags)
    {
        //see http://davidbehler.de/download/cloud.html
        $config['min_fon_size'] = 20;
        $config['max_fon_size'] = 60;
        
        $this->cloud->initialize($config);
        
        $this->cloud->add_tag($tags);
        return $this->cloud->get_cloud(' ', TRUE, TRUE);
    }

Also, is it possible that set_min_font_size and set_max_font_size are not used in your lib?
#16

[eluser]davidbehler[/eluser]
The index of your config array is wrong:
Code:
$config['min_font_size'] = 20;
$config['max_font_size'] = 60;

With that fix it should work
#17

[eluser]stef25[/eluser]
D'oh ... Thanks, works!




Theme © iAndrew 2016 - Forum software by © MyBB